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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.