Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function getCookie(cname, cb) {
  2. var name = cname + "=";
  3. var decodedCookie = decodeURIComponent(document.cookie);
  4. var ca = decodedCookie.split(';');
  5. for(var i = 0; i <ca.length; i++) {
  6. var c = ca[i];
  7. while (c.charAt(0) == ' ') {
  8. c = c.substring(1);
  9. }
  10. if (c.indexOf(name) == 0) {
  11. cb(c.substring(name.length, c.length));
  12. }
  13. }
  14. }
  15.  
  16. function selectAffiliateField() {
  17. // IMPORTANT: The form field ID where you want to store the cookie value
  18. var fieldId = "affiliate_id_f1687";
  19. return document.getElementById(fieldId);
  20. }
  21.  
  22. var affiliateFieldPresent = selectAffiliateField();
  23.  
  24. if (affiliateFieldPresent) {
  25. getCookie("affwp_ref", function(id) {
  26. selectAffiliateField().value = id;
  27. });
  28. getCookie("affwp_erl_id", function(id) {
  29. selectAffiliateField().value = id;
  30. });
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement