58 users online (1 members and 57 guests)  


  Results 1 to 4 of 4
  1. #1
    jvfleming's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    2

    Drop Down menu "other" *ree text option

    Hoping someone can direct me as how to get *ree text input in a drop down selection menu.

    Here is what I have so far:

    <SELECT NAME="job">
    <OPTION VALUE="Pharmacist">Pharmacist
    <OPTION VALUE="Technician">Technician
    <OPTION VALUE="Medical Service Representative">Medical Service Representative
    <OPTION VALUE="Other">Other</SELECT>

    What do I ned to add so that the person selecting "Other" can provide a *ree text input?

    Thanks

  2. #2
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    I have used this code before:
    Code:
    <html>
    <head>
    <script>
    function addOption(theSel){
     oc = theSel.options.length;
     if(theSel.selectedIndex==oc-1){
       newOpt = window.prompt("Enter Your Job","");
       if(newOpt+"">""){
         theSel.options[oc] = new Option(theSel.options[oc-1].text);
         theSel.options[oc-1] = new Option(newOpt, newOpt, true, true);
       }
     }
    }
    </script>
    </head>
    <body>
    <form>
    <select name="job" onChange="addOption(this)">
    <option>Please select
    <option>Technician
    <option>Medical Service Representative
    <option>Other 
    </select>
    <input type=submit>
    </form>
    </body>
    </html>

  3. #3
    jvfleming's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    2

    Thanks! That worked nicely.

    Corey,

    Thanks man. It works great. Wish my coding was not so rusty or so bad to begin with.




    Quote Originally Posted by coreybryant
    I have used this code before:
    Code:
    <html>
    <head>
    <script>
    function addOption(theSel){
     oc = theSel.options.length;
     if(theSel.selectedIndex==oc-1){
       newOpt = window.prompt("Enter Your Job","");
       if(newOpt+"">""){
         theSel.options[oc] = new Option(theSel.options[oc-1].text);
         theSel.options[oc-1] = new Option(newOpt, newOpt, true, true);
       }
     }
    }
    </script>
    </head>
    <body>
    <form>
    <select name="job" onChange="addOption(this)">
    <option>Please select
    <option>Technician
    <option>Medical Service Representative
    <option>Other 
    </select>
    <input type=submit>
    </form>
    </body>
    </html>

  4. #4
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    Glad it worked Someone gave me that code a long time ago & I use it when I need something like that.



Tags for this Thread