Guest User

Prefill Forms on secure Landing Pages using CGI Variables

a guest
Nov 17th, 2014
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. HOW TO: Pre-fill Order Forms on a secure Landing Page using Smart Form CGI variables
  2. Live example: http://yoursubdomain.ontraport.com/f/1/21729/58/8cec2e249b3b6759234a557b3df7569c
  3.  
  4. -----------------------
  5. -----INSTRUCTIONS------
  6. -----------------------
  7.  
  8. 1. Create Smart Form set to pass CGI variables, with secure TY page
  9. 2. A. Create Order Form to place on secure TY page > B. generate HTML > C. place Order Form on Landing Page using an HTML Layer
  10. 3. Next, obtain the input ID's for First Name, Last Name and Email fields using the Order Form HTML
  11.  
  12. These are what you're searching for: (Screenshot: http://screencast.com/t/sz1wfSmfy)
  13.  
  14. A. <input name="firstname" type="text" class="moonray-form-input" id="mr-field-element-926429679554"/>
  15. B. <input name="lastname" type="text" class="moonray-form-input" id="mr-field-element-989567682334"/>
  16. C. <input name="email" type="email" class="moonray-form-input" id="mr-field-element-383940685874"/>
  17.  
  18. The IDs are therefore: (Keep in mind, these will be unique to YOUR Order Form or Smart Form)
  19.  
  20. A. First Name = mr-field-element-926429679554
  21. B. Last Name = mr-field-element-989567682334
  22. C. Email = mr-field-element-383940685874
  23.  
  24. 4. In the script below, replace YOUR-FIELD-ID-HERE with the corresponding ID you found above
  25. EXAMPLE for First Name field:
  26. FROM: document.getElementById('YOUR-FIELD-ID-HERE').value = getParameterByName("firstname", url);
  27. TO: document.getElementById('mr-field-element-926429679554').value = getParameterByName("firstname", url);
  28.  
  29. NOTE: These IDs are unique to YOUR Form. This won't work for you using my IDs. :)
  30.  
  31. 5. Once you've filled in all IDs in the script, copy/paste the script immediately after the Order Form HTML in the SAME HTML Layer. I've found this is finicky if you place the Order Form HTML and script in separate layers. (I assume it depends on which loads first. Placing in the same layer avoids this issue.)
  32.  
  33. -----------------------
  34. -----SCRIPT BELOW------
  35. -----------------------
  36.  
  37. <script type="text/javascript">
  38. function getParameterByName( name,href )
  39. {
  40. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  41. var regexS = "[\\?&]"+name+"=([^&#]*)";
  42. var regex = new RegExp( regexS );
  43. var results = regex.exec( href );
  44. if( results == null )
  45. return "";
  46. else
  47. return decodeURIComponent(results[1].replace(/\+/g, " "));
  48. }
  49.  
  50. var url = window.location.href;
  51.  
  52. //Update the First Name field. Replace 'YOUR-FIELD-ID-HERE' below with the corresponding field ID.
  53. document.getElementById('YOUR-FIELD-ID-HERE').value = getParameterByName("firstname", url);
  54.  
  55. //Update the Last Name field. Replace 'YOUR-FIELD-ID-HERE' below with the corresponding field ID.
  56. document.getElementById('YOUR-FIELD-ID-HERE').value = getParameterByName("lastname", url);
  57.  
  58. //Update the Email field. Replace 'YOUR-FIELD-ID-HERE' below with the corresponding field ID.
  59. document.getElementById('YOUR-FIELD-ID-HERE').value = getParameterByName("email", url); //update email field
  60. </script>
Advertisement
Add Comment
Please, Sign In to add comment