rwtrwt2003 Posted February 2, 2010 Share Posted February 2, 2010 i have 2 fields. Field 1 is a option field that has multiple selection. Depending on what the selection is i want it to populate field 2. Here is the code for field 1 <label><strong>Switch: <select name="Switch" id="Switch" onchange="updateVendor(this.options[this.SelectedIndex].value)"> <?php while ($row_getSwitches = mysql_fetch_assoc($getSwitches)) { print "<option value='".$row_getSwitches['Switch']."'>".$row_getSwitches['Switch']."</option>\n"; } ?> </select> Here is the Java code that i am using <script type="text/javascript"> var Vendors = new Array(); <?php while($row_getVendor = mysql_fetch_assoc($getVendor)) { print "Vendors['".$row_getVendor['Switch']."'] = '".$row_getVendor['Vendor']."';\n"; } ?> function updateVendor(Switch) //Switch is current value of select box { if(Vendors[switch]){ document.getElementById('Vendor').value = Vendors[switch]; } alert(Vendors); } document.write("<input name=Vendors type=text id=Vendors >"); </script> Help Please Link to comment https://forums.phpfreaks.com/topic/190699-onchange-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.