Click to See Complete Forum and Search --> : Help
rexrr
08-01-2003, 07:49 AM
I have a page with a text box and a button. I have a page called 112233 and a page called 123456. When i enter the text 123456 i want it to link to 123456.htm anyone know if i can do this with Javascript and the code? Thanks for all you help.
Charles
08-01-2003, 08:00 AM
Yes, it's easily done in JavaScript. But how are you going to make it work for the 13% of users who do not use JavaScript?
rexrr
08-01-2003, 08:33 AM
Charles, thanks for the reply however this is just a test to show someone that if you enter a number it goes to a page and one that page it has some results. This is just a temp thing into I can get with the person and find out more about our server and stuff. I need to find out some info about the server and this is just to get by in a meeting
Vladdy
08-01-2003, 08:46 AM
<label>Enter Number:<input name="fileNumber" type="text" /><a href="#formsubmit" onclick="this.href=this.previousSibling.value + '.html'; return true">Go to page</a></label>
rexrr
08-01-2003, 08:52 AM
One more thing I am using Macromedia Dreamweaver do I put this javascript in the on button click(will it take the numbers in the text or in the form or in the text field?
If I enter the text above http://forums.webdeveloper.com/showthread.php?threadid=14447&goto=newpost I get an dug error, Should I put it on click or should i enter the javascript in both fields?
Vladdy
08-01-2003, 11:37 AM
Originally posted by rexrr
One more thing I am using Macromedia Dreamweaver ...
My condolences. The code I posted relies on the anchor element being adjuscent to the input, so I can avoid littering code with ids. God knows what kind of markup DW gives you.
Here is a better version of the code for you:
<form action="serversideredirect.php" onsubmit="this.action=this.elements['FileNumber'].value + '.html'; return true;">
<label>Enter File Number:<input type="text" name="FileNumber" value="" /></label>
<input type="submit" name="submit" value="Go To File" />
</form>
Still the whole thing is better done on server side, since it allows you to test file name if it exists and give an error message. As is it will just give a standard 404 page.