Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enable/disable/visible/hide textboxes based on option selected in selected tag

    I need to make a textbox visible and another hidden if a particular option is selected.Though I have a little bit idea I am not getting to anywhere.I request the forum members to help me out.

    Thanking in advance

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    function hideShowFields(oSel){
      var oFrm = oSel.form;
      switch (oSel.options[oSel.selectedIndex].value){
        case "red":
          oFrm.fieldToShow.style.display='inline';
          oFrm.fieldToHide.style.display='none';
          break;
        //...other cases
      }
    }
    ...
    <select onchange="hideShowFields(this)">
    <option value="blue">Blue</option>
    <option value="red">Red</option>
    ...
    </select>
    <input type="text" name="fieldToShow" style="display:none" value="hello" />
    <input type="text" name="fieldToHide" style="display:inline" value="world" />
    Last edited by glenngv; 03-22-2005 at 10:36 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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