A simple way to submit a form depending on the selected value from the dropdown box of the same form. We use the onclick event to call the javascript:
<form name="searchbar">
<select name="country">
<option value="fr">France</option>
<option value="es">España</option>
<option value="uk">United Kingdom</option>
</select>
<input type="button" value=" Search " onClick="goPage();">
</form>
And include the following javascript between the <head> tags of your page.
<script language="JavaScript" type="text/javascript">
function goPage (newURL) {
document.location.href = 'http://' + searchbar.country.value + '.' + ''yourwebsite.com/gothere.cfm' ;
}
</script>
When you click on the submit button, you will go to either:
fr.yourwebsite.com/gothere.cfm
es.yourwebsite.com/gothere.cfm
uk.yourwebsite.com/gothere.cfm
Best,
Harry Kuperus
Reacties