05-21-2007, 10:40 AM
Is there anyway that i can create a form, where depending on what the viewer types depends on what webpage they go to. I have a page where i want it to go.
For example. The viewer is on the home page (0), on that page there is a form. If they type in 1 it will go to page (1) or if they type in 2 it will go to (2), but if they type in a page that does not exist they get a custom error.
I'm not even sure this is the right section to put it in.:confused:
05-22-2007, 03:45 PM
From your description it is not clear whether the user is required to click a submit button or not after selecting the number.
05-23-2007, 09:37 AM
05-23-2007, 10:22 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
var el = document.getElementById('pagenum').options[document.getElementById('pagenum').options.selectedIndex].value;
if(el == 'none')
alert('You have not chosen a page number.');
window.location = el;
<form action="#" method="post" onsubmit="return goTo(this.pagenum.value)">
<select name="pagenum" id="pagenum">
<option value="none">Choose a page</option>
<option value="page1.html">Page 1</option>
<option value="page2.html">Page 2</option>
<option value="page3.html">Page 3</option>
<option value="page4.html">Page 4</option>
<input type="submit" value="Go">
I think the select menu is a little more user friendly than an input box.
05-23-2007, 10:29 AM
thanks alot mate. that seems great, but just out of interest what would need to be changed to make it an input box