...

View Full Version : HTML Form with Hyperlink as an input



susoxty
12-30-2005, 07:09 PM
I have a fairly simple question regarding a simple form i am creating.

In the form, there is to be one "input", which is a "download" link.

When the user clicks that link, it prompts a "Save Picture" dialog box, where the user can download the image to their computer.

What I want to do is create some sort of form validation, where in the "Save Picture" dialog box, if the user selects save and saves it to his/her computer, he/she is brought to a thank you page. If he/she clicks "cancel" nothing happen and the page should return false back to its orginal state. Any help will be greatly appreciated. Here is the current code. I know it's incomplete and a mess!



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cadillac Surprise & Delight</title>
</head>

<body>
<!--

/* This is the function that opens the 'save as' dialogue box in IE. */
/* It appears to fail gracefully in mozilla-based browsers but hsa not */
/* been fully tested */
-->

<script language="JavaScript">
function checkform()
{
if (value of first field is or isn't something)
{

return false;
}

return true;
}

</script>

<form action="" onSubmit="return checkform()">
<div>
<div class="thumb_img"><img src="/images/US/en/cadillac_surprise/thumb.jpg" border="0"></div>
<div class="thumb_txt"><a href="thankyou.html" onClick= return false">Download</a></div>
</div>
</form>

susoxty
12-30-2005, 07:52 PM
I've seemed to figure out most of the problem. I just now need to be redirected to the proper places after the form has been submitted.

If the person clicks "Save", i want them to be brought to a page called thankyou.html.

If the person clicks cance, i simply want the dialog box to close and the user to remain on that page.

here is the updated code:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cadillac Surprise & Delight</title>

<script type="text/JavaScript">
function SaveAs(status)
{
document.getElementById("iFrame1").src=status;
iFrame1.document.execCommand('SaveAs');
}
</script>
<SCRIPT language="JavaScript">
function submitform()
{
document.form1.submit();
}
</SCRIPT>

</head>

<body>
<iframe src="/images/US/en/cadillac_surprise/wallpaper.jpg" name="iFrame1" id="iFrame1" style="display:none;">
</iframe>
<br>
<form action="" name="form1" target="thankyou.html">
<div class="thumb_img"><img src="/images/US/en/cadillac_surprise/thumb.jpg" border="0"></div>
<div class="thumb_txt"><a href="="javascript: submitform()" onClick="SaveAs('/images/US/en/cadillac_surprise/wallpaper.jpg');">Download</a></div>
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum