Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML Form with Hyperlink as an input

    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!

    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>
    </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>

  • #2
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    almost there...

    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:

    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •