SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Display text box after combo box selected?

    I am wanting to display a text box after something in a combo box has been selected and I have no idea of where to start. Can someone please help me? Thanks in advance.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    HTML Code:
    <form name="theForm" action="whatever_your_action_is" >
    	Select here
    	<select name="theSelect" onchange="showTextField(this);">
    		<option>&nbsp;</option>
      		<option>First Option</option>
      		<option>Second Option</option>
    		<option>Third Option</option>
    	</select>
    	<input type="text" name="textBox1" size="10" style="display: none;" />
    	<input type="text" name="textBox2" size="10" style="display: none;" />
    	<input type="text" name="textBox3" size="10" style="display: none;" />
    </form>
    and the script:

    Code:
    function showTextField(el) {
    	if (el.selectedIndex) {
    		switch(el.selectedIndex) {
    		    case 1:
    			document.forms[0].elements['textBox1'].style.display = "";
    			break;
    		    case 2:
    			document.forms[0].elements['textBox2'].style.display = "";
    			break;
    		    case 3:
    			document.forms[0].elements['textBox3'].style.display = "";
    			break;
    		}
    	}
    }


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
  •