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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.