0

I have a multi page form.

Page One has a few fields that get passed into the second form, via GET method, and it auto fills the first four fields of the second part of the form.

Page two has a few more questions, and when you submit it, it submits into our CRM(vanillaSoft), and leads to a thank you page.

My current issue:

I want to be able to take an affiliate link, such as:

http://something.com/step-one.html?AFFILIATE_ID=#affid#&SUB_ID=#s1#

I need to dynamically populate the AFFILIATE_ID parameter with a unique transaction ID, and the SUB_ID with a unique ID as well.

I currently have two fields on my first page with hidden fields, ex:

<input type="hidden" name="SUB_ID">
<input type="hidden" name="AFFILIATE_ID">

But that isn't working. I need this date to be sent into the CRM I use.

Any advice?

Thanks!!!

Brian
  • 31
  • 4

2 Answers2

0

Your current setup will work if you set your form submit method to GET. You probably have it set to POST.

Setting your form method to GET will put those hidden fields in the URL, like you are expecting.

On the last form, set that one to POST (to POST to the server).

taco
  • 1,367
  • 17
  • 32
0

You can grab the Query string with JavaScript, like this:

var getParamValue = (function() {
    var params;
    var resetParams = function() {
            var query = window.location.search;
            var regex = /[?&;](.+?)=([^&;]+)/g;
            var match;

            params = {};

            if (query) {
                while (match = regex.exec(query)) {
                    params[match[1]] = decodeURIComponent(match[2]);
                }
            }    
        };

    window.addEventListener
    && window.addEventListener('popstate', resetParams);

    resetParams();

    return function(param) {
        return params.hasOwnProperty(param) ? params[param] : null;
    }

})();​

How can I get query string values in JavaScript?

You could also send both POST and GET methods. But POST can be done only on server side, where JavaScript is Client-side scripting language.

<form method="POST" action="form.php?a=1&b=2&c=3">

PHP -> Send both POST and GET in a form

How to read the post request parameters using javascript

Community
  • 1
  • 1
HelpNeeder
  • 6,383
  • 24
  • 91
  • 155
  • How would I go about implementing this code? For instance, this is my current setup: step_one.html: there are 4 fields that the user fills out, and those answers get sent via GET to the second part of the form, which is step_two.html step_two.html: the previous pages answers will populate this form, when the input name matches. After this form is filled out, it goes to our vanillasoft action via post. – Brian Sep 08 '14 at 04:59
  • So the first page gets into, sends it to the second form via GET, sends it via the url, but how can I capture the parameters from a url, on the first page, and carry that through to the last page submit into our CRM? – Brian Sep 08 '14 at 05:04
  • Ok, lets backtrack a bit. On first page the input fields must have a tag `value="ID-VALUE"` or `AFFILIATE-VALUE`. These values will be sent to second page by using `GET` as it appears now. The second page might have another form, where inputs will grab those 2 values as such: ``. From there, if user once more press the submit button again, this information will be passed to next page. – HelpNeeder Sep 08 '14 at 05:12
  • Seems like you having a problem grasping how to handle forms with php? http://www.w3schools.com/php/php_forms.asp – HelpNeeder Sep 08 '14 at 05:13
  • I am actually only using javascript – Brian Sep 08 '14 at 06:54
  • Ok, In this case you would submit the form with "value="VALUE"" set in the input fields, you would submit the form to the secondary document. In the secondary document you would use the code I posted in my OP, and you would call that function that will return an array of GET parameters. You would use those to enter the fields back into the form, and continue the execution from there. – HelpNeeder Sep 08 '14 at 13:36
  • Thanks for your help. Maybe you can help me a little more. My pages are http://smartreliefrx.com/qualify/step-one.html http://smartreliefrx.com/qualify/step-two.html http://smartreliefrx.com/qualify/thank-you.html I still can't pass anything. You have been a great help, and I would owe you if you could help me with this! Thanks! – Brian Sep 09 '14 at 15:21
  • I will take a look tonight. A bit busy at work at this moment. I'll try. – HelpNeeder Sep 09 '14 at 15:30