Trying to get selectedIndex value

Below is a copy of the code that I am working.  I have looked up the selectedIndex solution in the Javascript bible and implemented within the CalcStateFee function.  Why isn't it working???


<!--Javascript section-->
function CalcStateFee(form)
{
      
      alert("passing form object into CalcStateFee")
      var result = ""
      alert("result = " + result)
      result = (FormState.VmSys.options[FormState.VmSys.selectedIndex].value)
      alert("result = " + result)
      
      var opa8 = 0;        
    var opa8um = 0;         
      var opa8l = 0;  
      var opa8lum = 0;
      var Wvoicemail = 0;
            
            if(FormState.standard[0].checked)
            {
                  opa8 = opa8 + 1
                  alert("opa8 test worked")
                  
            }
            if(FormState.standard[1].checked)
            {
                  opa8l = opa8l + 1
                  alert("opa8l test worked")
                  
            }
            
      if(document.FormState.Wvoicemail.checked)
      {
            Wvoicemail = Wvoicemail + 1
      }      
      
      
      
      //variable calculation logic
      if(opa8 == 1)
      {
            if (Wvoicemail == 1)
            {
                document.FormState.CustomerName.value="opa8um";
               alert("document.FormState.CustomerName.value= " + document.FormState.CustomerName.value)
                        //document.FormState.submit();
                return false;
        }
          else
            {
                document.FormState.CustomerName.value="opa8";  alert("document.FormState.CustomerName.value= " + document.FormState.CustomerName.value)
                        //document.FormState.submit();
                return false;
        }
      }      
      
      if( opa8l == 1 )
      {
          if (Wvoicemail == 1)
            {
                document.FormState.CustomerName.value="opa8lum";
               //document.FormState.TestCity.value=result;
alert("document.FormState.CustomerName.value= " + document.FormState.CustomerName.value)
//alert("City Code submitted to boilerplate = " + document.FormState.TestCity.value)
                        //document.FormState.submit();
                return false;
        }
          else
            {
                document.FormState.CustomerName.value="opa8l";
                //document.FormState.TestCity.value = result
alert("document.FormState.CustomerName.value= " + document.FormState.CustomerName.value)
//alert("City Code submitted to boilerplate = " +  document.FormState.TestCity.value)
                        //document.FormState.submit();
                return false;
        }
      }            
<!--end variable submitting determination -->
}

<!--html section-->
<input type="hidden" name="CustomerName" value="">
<input type="hidden" name="VmSys" value="">

<!--end hidden field transmission -->
<tr><td><input type="radio" name="standard" value="opa8"><b>Standard ($9.95 per month)</b></td></tr>
<tr><td><input type="radio" name="standard" value="opa8l"><b>Standard ($18.95 per month)</b><p>
Add:<br></td>
<TD >Select City: <SELECT name="VmSys">
        <OPTION >--select one--</OPTION>
        <OPTION value="AT1">Austin</OPTION>
        <OPTION value="BA1">Birmingham</OPTION>
        <OPTION value="CN1">Charlotte</OPTION>
        <OPTION value="CT1">Corpus Christi</OPTION>
            <OPTION value="DT1">Dallas</OPTION>
            <OPTION value="ET1">El Paso</OPTION>
            <OPTION value="GN1">Greensboro</OPTION>
            <OPTION value="GS1">Greenville</OPTION>
            <OPTION value="HT1">Houston</OPTION>
            <OPTION value="LC1">Los Angeles</OPTION>
            <OPTION value="LK1">Louisville</OPTION>
            <OPTION value="NT1">Nashville</OPTION>
            <OPTION value="OF1">Orlando</OPTION>
            <OPTION value="PC1">Atlanta</OPTION>
            <OPTION value="PO1">Portland</OPTION>
            <OPTION value="RN1">Raleigh</OPTION>
            <OPTION value="SC1">San Francisco</OPTION>
            <OPTION value="ST1">San Antonio</OPTION>
            <OPTION value="SW1">Seattle</OPTION>
            <OPTION value="TO1">Toronto</OPTION>
</SELECT></TD></tr>

<tr><td><input type="checkbox" name="Wvoicemail" value="Add">Add Voice/Fax and Email<br></td></tr>

<tr>
<td>
Monthly Rate: <input type="text" name="monthly" size=10>
<p></td>
</tr>
<tr>
<td>

 <input type="submit" onClick="CalcStateFee(this.form)" value="sign up now!" name="submit">
</td>
</tr>

</form>
jerrykovachAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
xabiConnect With a Mentor Commented:
Hi there:

change this line:
result = (FormState.VmSys.options[FormState.VmSys.selectedIndex].value)
into this one:
result = document.FormState.example.options[document.FormState.example.selectedIndex].value

and this line:
<TD >Select City: <SELECT name="VmSys">
into this other:
<TD >Select City: <SELECT name="example">

xabi
0
 
xabiCommented:
I'm not sure what's happening, but ir seems it don't like uppercase in dropdown items name. With this changes it worked for me.

xabi
0
 
jerrykovachAuthor Commented:
For some reason the Vmsys variable was not being read correctly.  However, your solution was right on the money!!!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.