Solved

Trying to get selectedIndex value

Posted on 2000-02-14
3
803 Views
Last Modified: 2008-02-01
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>
0
Comment
Question by:jerrykovach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
xabi earned 70 total points
ID: 2519078
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
 
LVL 8

Expert Comment

by:xabi
ID: 2519088
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
 

Author Comment

by:jerrykovach
ID: 2519260
For some reason the Vmsys variable was not being read correctly.  However, your solution was right on the money!!!

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question