Jump to content

Onchange not working


rwtrwt2003

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.