dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Little problem with "select"

  1. #1
    Join Date
    Sep 2005
    Posts
    1

    Little problem with "select"

    Forgive my ignorance, but what I am trying to do is have a form where one of the select boxes does not appear unless another select box's option is selected. For Example one select is either Screws or Nails, if Screws is selected then another select box should appear and will have "coarse" or "fine" in it. This is what I have so far. This is only a test snipet. Thanks in advance.

    Here is my code:
    <html>
    <head>
    <script type="text/javascript">
    var text1;
    function newSelect() {
    var list = document.forms[0].select1;
    if(list.options[list.selectedIndex].value == "Screws") {
    var text1 = 1;
    }else{
    var text1 = "";
    }};
    </script>
    </head>
    <body>

    <form name="stuff1" action=get.php method=get>
    <select name="select1" onchange="newSelect()">
    <option><- Select Here -></option>
    <option value="Screws">Screws</option>
    <option value="Nails">Nails</option>
    </select>
    <script type="text/javascript">
    if(text1 == 1) {
    document.write("<select name=****2><option>Coarse</option><option>Fine</option></select>");
    };
    </script>
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910

  3. #3
    Join Date
    Sep 2004
    Posts
    361

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles