javascript problem
Posted: Fri Mar 09, 2012 5:30 am
hai Steve and all;
i have made a page which without refreshing shows the search result from database.
for that i have made a html form with javascript . i have tested it and it is working.
outside xataface .
the exact code is like this:
< html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>
this form onchange call the javascript and the javascript calls a getuser.php file which query the database and shows the result as a table.
i have tested it and its working. but i failed to integrate it with xataface main templates.
to integrate i have made a search.html form in templates folder and a action to show the templates as default as we make dashboard. i have included the javascript my application delegate class get included.
but when i am selecting the name in search page nothing happens . hopefully i think the javascript is not called at all. please help me to say where i am wrong.
thanks in advance
i have made a page which without refreshing shows the search result from database.
for that i have made a html form with javascript . i have tested it and it is working.
outside xataface .
the exact code is like this:
< html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>
this form onchange call the javascript and the javascript calls a getuser.php file which query the database and shows the result as a table.
i have tested it and its working. but i failed to integrate it with xataface main templates.
to integrate i have made a search.html form in templates folder and a action to show the templates as default as we make dashboard. i have included the javascript my application delegate class get included.
but when i am selecting the name in search page nothing happens . hopefully i think the javascript is not called at all. please help me to say where i am wrong.
thanks in advance