SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,618
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How do I make a combo box do this?

    I have a combo box of cities/areas within Los Angeles.
    How do I include a way to give them the option to select "other", and then a input box opens up allowing them to put in another city, and the combo box would simply be replaced?
    Thanks...
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you have so far?

  3. #3
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    play with this...

    HTML Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Example</title>
    <script type="text/javascript">
    	function check_other(e){
    		if(e.value == "other"){
    			var parent = e.parentNode;
    			var name = e.name;
    			parent.removeChild(e);
    			var textbox = document.createElement('input');
    			textbox.type = "text"
    			textbox.name = name;
    			textbox.size = 12;
    			parent.appendChild(textbox);
    		}
    	}
    </script>
    </head>
    
    <body>
    	<div>
    		<select name="area" onchange="check_other(this)">
    			<option value="a place">a place</option>
    			<option value="a place2">a place2</option>
    			<option value="other">other</option>
    		</select>
    	</div>
    </body>
    
    </html>
    you may want to change "textbox.size = 12;" to whatever width you want the textbox. also there is a div around the select box... i'd leave that or atleast make sure it's parent element only has it in it and nothing else.

    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,618
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Honestly, I tried another approach, but Alls seems alot simplier so I played with his. I modified the code a bit and if I select OTHER in the City drop down list nothing happens
    http://mylaasp.com/reviewform.php
    Thanks...
    Nevermind, I got it, works great though
    "Oh, and Jenkins--apparently your mother died this morning."


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
  •