#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    London
    Posts
    19
    Rep Power
    0

    Dynamic Menu with text-box option


    Hi,

    Im very new to javascript, and need a little help with some code.

    I have a script which i downloaded from another site, which is a pull-down-menu. Depending upon what you select, a text description is shown below.

    This is great, and all works fine. However, what i need to be able to do is if a user selects, say, the last option, I need to make 2 text boxes appear for data input, instead of the text description. I only need the text boxes for 1 of the options.

    Any help with this would be very much appreciated.

    Regards, Ben.

    Heres the code so far:-


    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF" text="#000000">


    <form name="a294" >
    <select name="a969" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.a294.a969.selectedIndex)">
    <option selected value="http://wsabstract.com">Website Abstraction </option>
    <option value="http://freewarejava.com">Freewarejava.com</option>
    <option value="http://wired.com">Wired News</option>
    <option value="http://freewarejava.com/cgi-bin/Ultimate.cgi">WA Help Forum</option>
    <option value="http://www.msnbc.com">MSNBC</option>
    </select>
    <input type="button" value="Go"
    onClick="location=document.a294.a969.options[document.a294.a969.selectedIndex].value"><br>
    <span id="descriptions" align="left" style="font:italic 13px Arial">
    </span>
    </form>

    <script>

    var textdisplay=new Array()
    textdisplay[0]="Comprehensive JavaScript tutorials and over 400+ free scripts"
    textdisplay[1]="Direct link to hundreds of free Java applets online!"
    textdisplay[2]="Up to date news on the technology front"
    textdisplay[3]="Interact with other webmasters on JavaScript, DHTML, and more."
    textdisplay[4]="National and international news"

    function displaydesc(which){
    if (document.all)
    descriptions.innerHTML=textdisplay[which]
    else if (document.getElementById)
    document.getElementById("descriptions").innerHTML=textdisplay[which]
    }

    displaydesc(document.a294.a969.selectedIndex)

    document.a294.a969.options[0].selected=true

    </script>

    </body>
    </html>
  2. #2
  3. No Profile Picture
    PHP Coder
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Ontario
    Posts
    66
    Rep Power
    14
    Uh... what does this have to do with Servlets & JSP?

IMN logo majestic logo threadwatch logo seochat tools logo