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
Solved

Trying to get selectedIndex value

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

856 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