Click to See Complete Forum and Search --> : Making a submit button work as a hyperlink


amatheya
08-03-2005, 04:18 PM
Hi,

Please help as I'm loosing the will to live!

I've made a form exactly as the tutorial on this site suggests and it works perfectly :o)

My only problem is that I want my submit button to also work as a hyper link so that when people pres submit there info is transmitted exactly as it is now but instead of being left on the form page I want it to automaticaly redirect to a thank you page.

I've left messages on a couple of web forms but people keep on trying to tell me how to get the submit button to send info to my email and that's not my problem... it's all very annoying.

Hope someone can save me...

Thanx

felgall
08-03-2005, 05:33 PM
It would depend on the script that is being called to process the form. That would need to be modified to redirect to the thankyou page if it doesn't already provide a way to pass the thankyou page to the script.

crazycoder
08-03-2005, 10:27 PM
If you form uses mailto:, then Try inserting this into your page.

Put this in the SUBMIT tag:

<SUBMIT onClick="parent.location='http://www.whatever.com/whatever.htm'" type="submit" value="blah blah blah">

If you use a script then ditto above.

MstrBob
08-03-2005, 11:29 PM
Well, two things. One, "mailto:" really should not be used on the web, just too unreliable. Second, you might not have to redirect at all. Depending on what you're using to process the form, this page itself can be the thankyou page. For instance, say you have:


<form action="form.php" method="post">
<fieldset>
<legend>Join our Mailing List</legend>
<label for="name">Your Name <input type="text" name="name" id="name"></label>
<label for="email">Your Email <input type="teext" name="email" id="email"></label>
<input type="submit" value="Join!" alt="Submit the Form">
</fieldset>
</form>


Now, you'd have form.php, which would process the form and thank the user:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Content-Style-Type" content="text/css">
<title>Your Mailing List Subscription</title>
</head>
<body>
<?PHP
$mailto = 'admin@example.com'; // Who to Mail
$subject = 'Mailing List Subscription'; // Subject of Email

if(!empty($_POST))
{
$results='--------------------------'."\n".'Form received on '.date('F j, Y')."\n\n";
$array=$_POST;
foreach($array as $key => $value)
{
$results.=$key.': '.htmlspecialchars(stripslashes($value))."\n\n";
}
if(@mail($mailto, $subject, $results)!==true)
{
echo('<h1>We\'re Sorry</h1>'."\n".'<p>We\'re sorry, but your subscription could not be submitted at this time.</p>');
}
} else {
echo('<h1>Thank You!</h1>'."\n".'<p>Your mailing list subscription has been submitted. Thank you for your interest!</p>');
}
?>
</body>
</html>

griff777
08-04-2005, 12:59 AM
Hi,

Please help as I'm loosing the will to live!

I've made a form exactly as the tutorial on this site suggests and it works perfectly :o)

My only problem is that I want my submit button to also work as a hyper link so that when people pres submit there info is transmitted exactly as it is now but instead of being left on the form page I want it to automaticaly redirect to a thank you page.

I've left messages on a couple of web forms but people keep on trying to tell me how to get the submit button to send info to my email and that's not my problem... it's all very annoying.

Hope someone can save me...

Thanx


Try this

<input type="submit" name="Button One" id="Button One" value="Some Page" onClick="location.href='somepage.htm'">
It worked in FF and IE.. Don't need a "FORM" to submit, it simply puts a button on the page, and viola, you have a button link.

Hope that helps.