View Single Post
  #3 (permalink)  
Old January 7th, 2006, 10:27 PM
minhtam minhtam is offline
Registered User
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Yes, the form id is "svcSearch" and the select box to be filled out by Javascript is named "specialty" as shown below.
The problem is that the global var speclist isn't seen by the function updateSpecialty. It works if declared locally, meaning that spelling isn't the problem. Thanks for looking at this with me.

<script type="text/javascript">
  var speclist=document.svcSearch.specialty // global variable
  function updateSpecialty(selectedProviderIndex) {
      // var speclist=document.svcSearch.specialty -- works if declared locally
      var specs=new Array();
      specs[1]=["X1|x1", "Y1|y1"]
      specs[2]=["X2|x2", "Y2|y2"]

      speclist.options.length=0 //clear list
    if (selectedProviderIndex > 0) {
        for (i=0; i < specs[selectedProviderIndex].length; i++) {
            speclist.options[speclist.options.length] = new Option(specs[selectedProviderIndex][i].split("|")[0], specs[selectedProviderIndex][i].split("|")[1])
--- and later followed by HTML
<form id="svcSearch" name="svcSearch" method="post" action="Results.php">

    <select name="svcProvider" size="6" id="svcProvider" onchange="updateSpecialty(this.selectedIndex)">

    <select name="specialty" size="6" multiple="multiple" id="specialty">


    <input type="submit" name="Find" value="Find"/>


Reply With Quote