View Full Version : Match user input to predefined list to determine next page

11-02-2012, 04:42 AM
I am trying to write a basic code to ask a user to input his zip code that will then be checked against a list of predefined zip codes. if input is matching user goes to one url if not matching goes to another.

any help would be great

Philip M
11-02-2012, 08:27 AM
Try this:-


<select id = "zipcodes" onchange = "checkzip()">
<option value = 0> Select your zip code</option>
<option value = 12345>12345</option>
<option value = 23456>23456</option>
<option value = 34567>34567</option>
<option value = "Other">Another zip code</option>

<script type="text/javascript">

function checkzip() {
var z = document.getElementById("zipcodes").value;
if (z == 0) {
return false; // do nothing
if (z == "Other") {
window.location.href = "http://www.google.com" // replace by the actual url
else {
window.location.href = "http://javascriptkit.com" // replace by the actual url



They are not inferior teams, they are just not as good. - Commentator Radio 5 Live