PDA

View Full Version : Resolved Input (text) box that redirects



Benjamin Malin
Dec 15th, 2008, 05:04 AM
I want to know if it is possible to have an empty input box that redirects to different pages when a specific code is entered.

For example:
The text box is on "index.html". When someone enters "123" in the box and presses the 'go' button, they are sent to "anotherpage.html". When they enter "456" in the box and press the 'go' button, they are sent to "athirdpage.html".

Is this possible? Or should I be using a different file type?

drhowarddrfine
Dec 15th, 2008, 06:25 AM
Not that simple. The entry can be POSTed and your server side language redirect it but that's the only way.

Benjamin Malin
Dec 15th, 2008, 08:18 AM
Thanks for replying.

I'm not very advanced when it comes to HTML, though. How would POST work here? And what would I have to do to get it to work on my site?

Fou-Lu
Dec 15th, 2008, 08:27 AM
Technically you can do some of this in JS. Javascript isn't a reliable means to control this though, and it will get pretty brutal once you have a number of redirectable pages. As well, you'll be able to see in you're JS what is required to be entered in order to proceed to specific pages.
So, as drhowarddrfine mentioned, you'll need to post you're form. This means you need to look at a processing language to handle what has to happen with the form data. Common ones are PHP, Perl, ASP/ASP.NET, JSP, ColdFusion and Ruby. These all depend on you're server though, PHP and Perl are likely available for you no matter what system you're on. JSP and ASP are slightly more difficult to find, and ColdFusion is likely out of scope (though I'm expecting a resurgance due to increased FLEX interest).

So, to post from HTML its a simple form:


<form action="myprocessing.php" method="post">
<input type="text" name="code" />
<input type="submit" name="submit" value="Submit" />
</form>

Then you need to roll into you're processing page (in my example, its myprocessing.php; it will be whatever is in the 'action' attribute on a form).

Benjamin Malin
Dec 16th, 2008, 01:33 PM
Thanks, got it.:o