SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Forms & Combining Fields...?

    Hi,

    I'm in the process of setting up a site which offers a fixed price service, and thinking of going with (payment service provider) Worldpay Select Junior.

    For me to provide the service, I need customers to give me three specific pieces of data.

    However, I can't pass that data onto Worldpay as three fields! They first need to, somehow, be combined into one field!

    So this is how far I have got:

    I have a form with three fields (eg 'field1', 'field2', 'field3'). Once a customer completes the form and clicks submit, the three fields get validated.


    Now, this is what I'm stuck on:

    1) What I then want is those three fields to be summarised into a new field (eg 'summarised_field').

    2) Then finally I want the form with the new field ('summarised_field') to be posted to the Worldpay payment page (but not with the original three fields).


    Anyone know how to do this?

    Thanks.

  2. #2
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...

    Code:
    <script type="text/javascript" language="JavaScript">
    function summarize()
    {
     var strSummary = '';
     strSummary += document.form1.input1.value
    	+ document.form1.input2.value
    	+ document.form1.input3.value;
     document.form2.summary.value = strSummary;
     document.form2.submit();
    }
    </script>
     
    ......
    ......
     
    <form name="form1">
     <input name="input1" type="text" value="" /><br />
     <input name="input2" type="text" value="" /><br />
     <input name="input3" type="text" value="" /><br />
    </form>
    <form name="form2" action="about:blank" onsubmit="summarize()">
     <input name="summary" type="hidden" value="" />
     <input name="btnSubmit" type="submit" value="Submit" />
    </form>
    Hope that helps,
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Karloff, I've quickly tested your script and it works. Now I just have to integrate it with my validation script.

    You wouldn't happen to know which browsers your script is compatible with would you? Netscape? I've got Internet Explorer (v5, I think!).

    Thanks for your help Karloff, I really appreciate it!
    Last edited by Hit; Apr 27, 2003 at 06:23.

  4. #4
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I only have IE 6, NS 6 & 7 as well as Moz 1.3 and 1.4a and in those it works fine. As it is the simplest of JavaScripts, I don't see a reason why it shouldn't run even on older or more exotic browsers.

    Happy scripting,
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Karloff, that's a relief!


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
  •