Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can not retrive values in combo box.Here is my code.
C#
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","systemdate.php?inputField="+str,true);
xmlhttp.send();
};
</script>


PHP
<?php
$inputField=$_GET['inputField'];
$res1="SELECT DISTINCT time FROM import WHERE date1='".$inputField."'";
while($row=mysql_fetch_assoc($res1))
 {
echo "<option value=$row[time]>$row[time]</option>";
}
echo "</select>";
?>
Posted

1 solution

you are not rendering "<select>" i.e. the beginning tag for a combo box, may be that's why its not working, try echoing the begin tag before the while loop. Also try using jQuery AJAX[^] rather than the old fashioned XMLHttpRequest way.
 
Share this answer
 
Comments
project virus 10-Aug-12 6:42am    
No I took <select> tag in my original code
I.explore.code 10-Aug-12 6:55am    
shouldn't this : "<option value=$row[time]>$row[time]</option>" be : "<option value=".$row[time].">".$row[time]."</option>" instead?? because presently, its all one string to access PHP array you need to inline the PHP with the string like i mention.
project virus 10-Aug-12 7:04am    
no,not working.Is there any problem getting in ajax code.
I.explore.code 10-Aug-12 7:12am    
are u getting any error? try doing a var_dump in your PHP script to make sure the query is returning the data. Also fire-up Firebug or Fiddler to see the requests being made and see what responses are being returned. You are gonna have to do a bit of investigation at your end to find any errors.
project virus 10-Aug-12 7:14am    
sorry not get ur point.What I have to do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900