modify the default option in a select changing another select

Discussion in 'Javascript' started by WebRaster, Oct 26, 2005.

  1. WebRaster

    WebRaster Guest

    I wish to know if is possible to change the selected option in a SELECT
    selecting a determined option into another SELECT in the same form.


    E.g: When I select the option "Istruction" in the SELECT named "A" I wish
    the SELECT "B" change the default state from "empty" to "other"

    Thank You
     
    WebRaster, Oct 26, 2005
    #1
    1. Advertising

  2. Here is a litle example of...
    <html>

    <body onload="changeEvent()">

    <script language="JavaScript">
    <!--
    function changeEvent() {
    if (document.forms[0].items.selectedIndex == 0)
    document.forms[0].subItems.selectedIndex = 1;
    if (document.forms[0].items.selectedIndex == 1)
    document.forms[0].subItems.selectedIndex = 0;
    }
    -->
    </script>

    <form method="POST" action>
    <p><select size="1" name="items" onchange="changeEvent()">
    <option>Item1</option>
    <option>Item2</option>
    </select><select size="1" name="subItems">
    <option>SubItem1</option>
    <option>SubItem2</option>
    </select></p>
    </form>
    </body>

    </html>
     
    Francisco Spaeth, Oct 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Hall
    Replies:
    2
    Views:
    1,106
    Jeff Thies
    Apr 21, 2004
  2. David Clark

    SELECT OPTION: changing dynamically

    David Clark, Aug 3, 2003, in forum: Javascript
    Replies:
    7
    Views:
    119
    Lasse Reichstein Nielsen
    Aug 5, 2003
  3. palmiere
    Replies:
    1
    Views:
    452
    Erwin Moller
    Feb 9, 2004
  4. Monty
    Replies:
    2
    Views:
    159
  5. Nick Spacek

    Removing select option removes entire select

    Nick Spacek, Jun 21, 2006, in forum: Javascript
    Replies:
    1
    Views:
    157
    Matt Kruse
    Jun 21, 2006
Loading...

Share This Page