Passing a form twice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shisou
    New Member
    • Jul 2007
    • 52

    Passing a form twice

    So I'm woking on a page with a form and I've run into a problem. I need my form to be submitted to two places. First it needs to be passed to my ASP code which will send an email using data on the form. After the email is send it needs to be submitted to another website. This other website is basically looking for specific information to be submitted and it will take it into a database. I have no control over this database or the site.

    is there anyway that I can do this in asp? basically take in the form and resubmit it after it's done with it's work?

    I appreciate any help I can get!
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Shisou,

    You sure can if you use a bit of javascript. Place this line in your html and it will automatically submit your form when it is reached:
    Code:
    <script type="text/javascript">document.form1.submit();</script>
    All you need to do is change form1 to the name of the form you're submitting.

    I would store all the data submitted from the first page as hidden fields on the second page (which sends the e-mail) and then submit that form using the javascript to the third, external, page.

    Page 1.asp
    Code:
     <form name="form1" action="Page2.asp"> 
    <input type="text" name="Input1" />
    <input type="submit" value="Submit" />
    </form>
    Page2.asp
    Code:
    <%
    Dim sInput
    sInput = Request("Input1")
     
    ....e-mail code goes here...
    %>
    <form name="form2" action="ExternalWebsite.asp">
    <input type="hidden" name="Input1" value="<%=sInput%>" />
    </form>
    <script type="text/javascript">document.form2.submit();</script>
    Does this make sense? Let me know if it helps,

    Dr B

    Comment

    • Shisou
      New Member
      • Jul 2007
      • 52

      #3
      I think i get what you're saying... so I submit the form first to my asp page to have the email sent, then in the html portion of the second page i rebuild the form (kinda) and use JS to submit it again to the third (external) site.... should i put the JS anywhere inparticular on the second page (head, body, ect..) since I think it will behave differently depending?

      Comment

      • Shisou
        New Member
        • Jul 2007
        • 52

        #4
        YAY!

        This worked like a charm, I haven't tested it going to the third site yet because it needs to be in production to do that, but the email sends perfectly and through some testing i see the form values pass without issue.

        Thank you again! I don't know what I would do without this site :D

        Comment

        • DrBunchman
          Recognized Expert Contributor
          • Jan 2008
          • 979

          #5
          Originally posted by Shisou
          YAY!

          This worked like a charm, I haven't tested it going to the third site yet because it needs to be in production to do that, but the email sends perfectly and through some testing i see the form values pass without issue.

          Thank you again! I don't know what I would do without this site :D
          No problem, I'm glad I could be of help :-)

          Dr B

          Comment

          Working...