onChange problem with two dropdowns and one form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    onChange problem with two dropdowns and one form

    I have a form with two single-choice dropdowns. Upon doing an onChange
    event on either one of them, I want to check to see if the other dropdown
    has also been selected. How would I do that, considering that this.parent
    causes an error "null or not an object"?

    Thanx
    Phil


  • Lee

    #2
    Re: onChange problem with two dropdowns and one form

    Phil Powell said:[color=blue]
    >
    >I have a form with two single-choice dropdowns. Upon doing an onChange
    >event on either one of them, I want to check to see if the other dropdown
    >has also been selected. How would I do that, considering that this.parent
    >causes an error "null or not an object"?[/color]

    The "parent" attribute is an attribute of windows.
    Form elements have an attribute named "form", which is a reference
    to the containing form.

    <html>
    <head>
    <script type="text/javascript">
    function seeIfBothChosen (f){
    if(f.select1.se lectedIndex && f.select2.selec tedIndex){
    alert(f.select1 .options[f.select1.selec tedIndex].text + " / " +
    f.select2.optio ns[f.select2.selec tedIndex].text);
    }
    }
    </script>
    </head>
    <body>
    <form>
    <select name="select1" onchange="seeIf BothChosen(this .form)">
    <option>--Choose--</option>
    <option>alpha </option>
    <option>beta</option>
    </select>
    <select name="select2" onchange="seeIf BothChosen(this .form)">
    <option>--Choose--</option>
    <option>gamma </option>
    <option>delta </option>
    </select>
    </form>
    </body>
    </html>

    Comment

    • Phil Powell

      #3
      Re: onChange problem with two dropdowns and one form

      Ok cool, is there then an easier way to check then that if one dropdown has
      been selected that so has the other within the same form?

      Thanx
      Phil

      "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
      news:bktfla0e0l @drn.newsguy.co m...[color=blue]
      > Phil Powell said:[color=green]
      > >
      > >I have a form with two single-choice dropdowns. Upon doing an onChange
      > >event on either one of them, I want to check to see if the other dropdown
      > >has also been selected. How would I do that, considering that[/color][/color]
      this.parent[color=blue][color=green]
      > >causes an error "null or not an object"?[/color]
      >
      > The "parent" attribute is an attribute of windows.
      > Form elements have an attribute named "form", which is a reference
      > to the containing form.
      >
      > <html>
      > <head>
      > <script type="text/javascript">
      > function seeIfBothChosen (f){
      > if(f.select1.se lectedIndex && f.select2.selec tedIndex){
      > alert(f.select1 .options[f.select1.selec tedIndex].text + " / " +
      > f.select2.optio ns[f.select2.selec tedIndex].text);
      > }
      > }
      > </script>
      > </head>
      > <body>
      > <form>
      > <select name="select1" onchange="seeIf BothChosen(this .form)">
      > <option>--Choose--</option>
      > <option>alpha </option>
      > <option>beta</option>
      > </select>
      > <select name="select2" onchange="seeIf BothChosen(this .form)">
      > <option>--Choose--</option>
      > <option>gamma </option>
      > <option>delta </option>
      > </select>
      > </form>
      > </body>
      > </html>
      >[/color]


      Comment

      Working...