Solved

Trying to get selectedIndex value

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to escape unsafe HTML tags 4 36
Put POST values into cookies. 14 34
Table header must be on top 2 31
Javascript: Mouseup doesn't follow mousedown 13 34
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

726 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