SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Enable text box onchange drop down menu

    Hi, How do you make a function that will enable a disabled text box when a user clicks "others" in the drop down menu.. http://kabatak.ultradesigns.net/help.htm

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you haven't posted any code, I can't provide a clearer solution. Essentially, you:

    1. Attatch an onChange event to your dropdown, which calls your evaluation function

    2. Each time the evaluation function is called, evaluate the selectedIndex

    3. If the selectedIndex is == to OTHER, then use the DOM to enable your textbox. Otherwise, disable your textbox.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you, im not really familiar with JS so i dont understand it fully but someone gave me the answer, in case anyone is interested, here it is.
    Code:
    <script language="javascript">
    function dis_able()
    {
    	if(document.myform.D1.value != 'Others')
    		document.myform.otherz.disabled=1;
    	
    	else
    		document.myform.otherz.disabled=0;
    }
    </script>
    <form name="myform">  
      Category: <select size="1" name="D1" onChange="dis_able()">
      <option>Category A</option>
      <option>Category B</option>
      <option>Catagory C</option>
      <option value="Others">Others</option>
      </select><br>
      Others pls specify: <input disabled type="text" name="otherz" size="20" value="pls specify"></p>
      <p><input type="submit" value="Submit" name="B1"></p>
    </form>


Bookmarks

Posting Permissions

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