javascript problem

A place for users and developers of the Xataface to discuss and receive support.

javascript problem

Postby samhans » 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
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: javascript problem

Postby shannah » Fri Mar 09, 2012 10:34 am

Hard to comment with this amount of information. Troubleshooting Javascript involves:
1. Checking your javascript error log and following clues.
2. Reviewing the resulting Page source to see that the javascript is actually included.
3. Adding messages in javascript at various points to see what code is executing (e.g. using console.log() if you are using chrome, safari, or Firefox - or just alert() otherwise).


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: javascript problem

Postby samhans » Fri Mar 09, 2012 10:43 am

Steve the code is ok i have checked it and its working. please check the xmlhttp.open tag in my javascript. is this will work in xataface
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: javascript problem

Postby shannah » Fri Mar 09, 2012 10:49 am

Anything that will work outside Xataface will work inside Xataface.
You just have to be aware of your context and environment.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: javascript problem

Postby samhans » Fri Mar 09, 2012 10:53 am

Steve can i included javascript inside the macro tag in my search html template.
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 13 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved