TehBlizzy Posted October 16, 2006 Share Posted October 16, 2006 Ello. My current site right now is called Death's Maze. It is where you type in your direction into a text box and click a button, then using Javascript, redirects you to a page depending on the direction you type.My problem is, what HTML coding should I use to make the button submit the text in the text box into a Javascript file.Then, what codes should I use to make it that, depending on the text, redirects you to another page.Such as, if I typed "Up" in the text box, then clicked the button, the Javascript code would read that and direct me to the second part, but if I typed anything else such as "Left", it would take me to another page as a dead end.Hope that isn't too complicated. I use PS Pad, IE, Firefox, and an external Javascript page(JS/Javascript.js)If possible, I don't want the button to bring up a prompt box. Ty for your help =D Link to comment Share on other sites More sharing options...
TehBlizzy Posted October 17, 2006 Author Share Posted October 17, 2006 66 views and still no reply > Link to comment Share on other sites More sharing options...
jhecht Posted October 18, 2006 Share Posted October 18, 2006 are you saying that you have a text box, and when you type something into it and hit submit the text is inputted into javascript and it then redirects to a seperate page depending on what you type, or does it redirect you to a part of the page you are already on?and if you want javascript to submit when a button is clicked: <input type="button" onclick="jsFunction(document.formname.fieldname.value)" value="Submit"/> Link to comment Share on other sites More sharing options...
TehBlizzy Posted October 21, 2006 Author Share Posted October 21, 2006 The first part that you said is what I'm trying to do Link to comment Share on other sites More sharing options...
jhecht Posted October 21, 2006 Share Posted October 21, 2006 It would be alot of code. Do you just want like "up, down, left, right" as possible inputs or do you want ANYTHING as a possible input? From there i can try to code you something but i can't guarantee it'll do what you want. Link to comment Share on other sites More sharing options...
TehBlizzy Posted October 22, 2006 Author Share Posted October 22, 2006 Ya, just up, left, and right will do it =P Link to comment Share on other sites More sharing options...
jhecht Posted October 22, 2006 Share Posted October 22, 2006 ok then this isnt as complex as i thought it would be, i thought you meant like any word they put in let them go to a different page. <script type="text/javascript"><!--function check(name){ switch(name){ case "up": window.location="pageforup.html"; break; case "left": window.location="pageforleft.html"; break; case "right": window.location="pageforright.html"; break; default: return false; break; }}//--></script> now call it like this:<form name="jim" action="page.php" onsubmit="return false" method="post"><input type="text" name="page"/><input type="button" name="submit" onclick="check(this.parentNode.page.value)"/></form>if that doesnt work then just change this.parentNode.page.value to document.jim.page.value; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now