PDA

View Full Version : On click redirection from form and external index



whoknowswhat
12-22-2007, 10:20 PM
Hello,

I found this thread here (http://www.dynamicdrive.com/forums/showthread.php?t=9474)

And I am wanting something just a little different.

The code I have is as follows


<head>
<script type="text/javascript" src="num.js"></script>
</head>

<body>

<form action="" method="get" onsubmit="this.action = 'http://www.graceservicesgroup.com/' + this.elements['code'].value.toLowerCase() + '.html'; return true;">
<fieldset>
<legend>Code entry form</legend>
<input type="text" name="code" id="code" size="15">
<label for="code">Enter Code:</label>
<input type="submit" value="Submit">
</fieldset>
</form>

</body>


This is just the example code from the thread above with my own url as well as my script.

What I am looking to do is take the form data and compare it to a javascript that contains the links and their code. Then have the link associated with the form entry to be returned and then redirect to the returned link.

The desired output is that if 0 is entered and submitted it will redirect the user to http://support.graceservicesgroup.com/
And other numbers to other places, such as the homepage or a promotional page.

Any assistance is greatly appreciated!

whoknowswhat
12-23-2007, 12:31 AM
Please, any help at all will be appreciated, I have no idea where to start or what I should use to make the redirection index or how I would make it, even pointers would help

How would I use the form data to look up the number in the index
How would I return the string from the index to redirect the window to the desired link

I just need some pointers

Thanks in advance:confused:

Edit:

num.js


if (num=="0")
document.location="http://www.graceservicesgroup.com/support.html";

jscheuer1
12-23-2007, 09:34 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.script {
display:none;
}
</style>
<script type="text/javascript">
function gotoit(num){
if (num=="0")
window.location="http://www.graceservicesgroup.com/support.html";
}
document.write('<style type="text/css">.noscript {display:none;}.script{display:block;}<\/style>');
</script>
</head>
<body>
<div class="script">
<form action="#" onsubmit="gotoit(this.elements[0].value);return false;">
<div><input type="text">
<input type="submit" value="Go">
</div></form>
Enter 0 for Support
</div>
<div class="noscript">
<a href="http://www.graceservicesgroup.com/support.html">Support</a>
</div>
</body>
</html>

whoknowswhat
12-23-2007, 05:05 PM
Thanks, That is just like I needed. I even got the javascript in a .js file to hold all the locations in to work from that!

num.js:


function gotoit(num){
if (num=="0")
window.location="http://www.graceservicesgroup.com/support.html";
if (num=="01")
window.location="http://www.graceservicesgroup.com/flash/";
}
document.write('<style type="text/css">.noscript {display:none;}.script{display:block;}<\/style>');


testnum.html:



<head>

<script type="text/javascript" src="num.js"></script>

</head>


<body>

<div class="script">
<form action="#" onsubmit="gotoit(this.elements[0].value);return false;">
<div><input type="text">
<input type="submit" value="Go">
</div></form>
Enter 0 for Support
</div>
<div class="noscript">
<a href="http://www.graceservicesgroup.com/support.html">Support</a>
</div>

</body>


Thanks for all your help!