Solved

Trying to get selectedIndex value

Posted on 2000-02-14
3
768 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now