SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member Stevewilliamson's Avatar
    Join Date
    Nov 2001
    Location
    Nhulunbuy NT
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Small question on submission

    I am trying to design a link that submits a from through from action and mailto:? without using server side!

    Problem is when the user submits data, I want them to be passed to a URL that contains the link for the download.

    Any ideas?

    See http://www.alternativeaccess.com.au/brochure_1.htm for the thing I am trying.
    Steve Williamson
    Teknoledgi Pty Ltd
    www.teknoledgi.com.au

  2. #2
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to use JavaScript, I think:
    PHP Code:
    <script>
      function 
    submit_form() {
        
    document.forms.formName.submit(); // Replace form name, of course
        
    location.href "./new-site/download";
      }
    </script>
    <form id="formName" name="formName" action="mailto:address@example.com">
      <!-- The rest of your form goes here -->
      <button onclick="submit_form()">Download</button>
    </form> 
    But it doesn't work for every browser. BTW, I don't know if this script will work, I'm just using it as an example. If someone sees something wrong with it, please fix it. I'm no JavaScript expert. :-)

    I have no idea why the last part of the button and the closing tag has been cut off. They aren't in the edit mode is this, so really confusing!


    ~~Hope This Helps
    Last edited by Ian Glass; Dec 2, 2001 at 19:28.

  3. #3
    SitePoint Member Stevewilliamson's Avatar
    Join Date
    Nov 2001
    Location
    Nhulunbuy NT
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Getting there, however, it tries to send the form by email twice!!

    Help

    Steve
    Steve Williamson
    Teknoledgi Pty Ltd
    www.teknoledgi.com.au

  4. #4
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try reconfuring your validate script to this:
    function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
    if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R') {
    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
    min=test.substring(8,p); max=test.substring(p+1);
    if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    }
    if (errors)
    {
    alert('The following error(s) occurred:\n'+errors)
    document.MM_returnValue = (errors == '')
    return false
    }
    else
    {setTimeout("location.href = 'brochure_2.htm'",1000)}

    Then use the onSubmit event in the form tag to perform the script when you click the submit button.
    <form name="mail" method="post" action="mailto:itnt@kooee.com.au" enctype="text/plain" onSubmit="return MM_validateForm('Name','','R','Company Name','','R','Position','','R')">

    also remove the onClick from the submit button. To get it to go to the download page you will need to use a delay for the mail server to have time to respond back to the submit. Try it and see if it works and good luck.

  5. #5
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you are trying to make you submit_form(); function submit by mail and redirect to brochure2.htm AND you are also submitting the form by POST via your email. Thus the 2 email submissions. So, keep the form ACTION your email address and change this function:
    Code:
    function submit_form() {
        MM_validateForm('Name','','R','Company Name','','R','Position','','R');
    	document.forms.mail.submit(); // Replace form name, of course	
    	location.href = "brochure_2.htm";
      }
    to this:
    Code:
    function submit_form() {
        MM_validateForm('Name','','R','Company Name','','R','Position','','R');
    	location.href = "brochure_2.htm";
      }
    Not sure if this will work or not, but give it a whirl.

    Sketch
    Aaron Brazell
    Technosailor



  6. #6
    SitePoint Member Stevewilliamson's Avatar
    Join Date
    Nov 2001
    Location
    Nhulunbuy NT
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gave up!

    Thanks, but in the end gave up and used php mail function with simple echo to give link to download.

    Tried to do it without server side programming, to cumbersome in the end.
    Steve Williamson
    Teknoledgi Pty Ltd
    www.teknoledgi.com.au


Bookmarks

Posting Permissions

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