View Full Version : Dynamic Form with Dropdown Menu and Text Box

11-01-2013, 09:06 PM
Hi All, not sure if this is a javascript question or a form question, but I have a new project Im working on regarding a form.

People have a drop down menu within this script or form that has three choices. Each choice needs to reference a different URL for the choice, and then go to it on Submit. Thats the easy part. The hard part is that the script/form also has a text box in it that has a zip code to be placed inside. So for example, someone chooses the first option, and puts in a zipcode within the text field and hits "submit", so when its submitted it goes to a URL + the zipcode.

<form name="URL_TEST">
<input type="text"/>
<select name="selected" id="target">
<option selected>Select...</option>
<option value="http://www.URL1.com/page?zipcode=[ZIPCODE]">WEBSITE1</option>
<option value="http://www.URL2.com/page?zipcode=[ZIPCODE]">WEBSITE2</option>
<option value="http://www.URL3.com/page?zipcode=[ZIPCODE]">WEBSITE3</option>
<input type="submit" name="submit" id="submit" value="Submit"/>

This is kind of a crude bit of code, I know (just took it briefly from dreamweaver), but what Im trying to do with the above is have the "input type="text"" be filled it, and connected to one of the "[ZIPCODE]" options on submit. So you can put a zipcode into the text field, choose option one, hit submit, and it will go to the URL, replacing the "ZIPCODE" area of the URL with the zipcode that was typed in. Im sure this is more complicated, but Im not sure where to start/complete/finish this. Any ideas? Thanks