I am trying to connect 2 select boxes together.
What I have in mind is this: The user chooses a userid from the first select box. Once they select the userid it projects data based off only the userid.
There is a second select box that holds year values so that once a year is selected it will filter the data of that userid to only show for that specific year.
I'm not that well with Javascript so I don't know what exactly I'm trying to do in the Javascript area.
*******Select Box1*******HTML Code:<script type="text/javascript"> function saveUser(userid) { var userid; showUser(userid); } function saveYear(year) { var year; showUser(year); } function showUser(userid,year) { if (userid =="" && year =="") { 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","Status_23Gs.php?q="+userid+"&year="+year,true); xmlhttp.send(); } </script>
PHP Code:
<?php
$query="SELECT uuid,auth,emp FROM auto_atp.Admin";
$result=mysql_query($query);
$options="";
while($row = mysql_fetch_array($result)){
$id=$row['uuid'];
$users=$row['uuid'];
$options.="<OPTION VALUE=\"$id\">".$users;
}
?>
<b>UUID:</b><select id="theuser" name="users" onchange="saveUser(this.value)">
<OPTION VALUE=0><b>UID</b>
<?=$options?>
</SELECT>****OUTPUT********PHP Code:*****Select Box 2*******
<?php
$query="SELECT serial,year FROM auto_atp.GeoProbe GROUP BY year ORDER BY year";
$result=mysql_query($query);
$options="";
while($row = mysql_fetch_array($result)){
$RES=$row['year'];
$options.="<OPTION VALUE=\"$RES\">".$RES;
}
?>
<select id="theyear" name="year" onchange="saveYear(this.value)">
<OPTION VALUE=0>
<?=$options?>
</SELECT>
<div id="txtHint"><b></b></div>


Reply With Quote
Bookmarks