Question with AJAX and JQuery datepicker
Hi,
I'm new to JQuery and playing around with it. I am using a JQuery datepicker on my site and its used for entering data into a MySQL database. I have php code which displays the data by day as the user inputs it, but I would like to replace this with AJAX. I found an example on the web but I have a question.
<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>
The variable they pass to the function is the value number from the select list. Of course the value I want to pass is the date when selected on the calendar so I'm wondering if I can do this:
onchange="showUser(this.dateText)"> instead and will that work? Will it pass the JQuery date variable or am I on the wrong track. Thanks in advance for your help!