{"__v":7,"_id":"571f9142ada30c34003b7cd9","category":{"__v":0,"_id":"571f73cfcb4baa0e00d13a80","project":"571f5e8cd8667f0e00a3c498","version":"571f5e8cd8667f0e00a3c49b","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-04-26T13:57:35.810Z","from_sync":false,"order":2,"slug":"form-prepopulation","title":"Form-Prepopulation-API"},"parentDoc":null,"project":"571f5e8cd8667f0e00a3c498","user":"571f5e46d8e3cf1900762b33","version":{"__v":12,"_id":"571f5e8cd8667f0e00a3c49b","hasDoc":true,"hasReference":true,"project":"571f5e8cd8667f0e00a3c498","createdAt":"2016-04-26T12:26:52.312Z","releaseDate":"2016-04-26T12:26:52.312Z","categories":["571f5e8cd8667f0e00a3c49c","571f73cfcb4baa0e00d13a80","571f7451cb4baa0e00d13a88","571f7d2720695f3400f38797","571f7fb0ac2a080e0014c661","571f884be54f2d0e003ebb0a","572200c9ecb38d0e00d80ebd","572c301e7c8eff0e00aaa174","57df91b2c6348d0e0020c452","57e104db9ff1e21900a721ab","57fd04caeaa77f19008b8202","5899c7113514ce0f0014da84"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-26T16:03:14.840Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Append parameters to your URL\"\n}\n[/block]\nFor example your URL to your donation form is: http://www.myorga.com/donate.html so you can just append the parameters to your URL. \n- pro: this is the most easiest way\n- con: the parameters are visible to the user, so of course these can be manipulated in the URL\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"http://www.myorga.com/donate.html?amount=12.34&interval_fix=6&fb_item_id=789\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Append parameters to your Javascript-Embed-Code\"\n}\n[/block]\nIf you want to do a \"hidden\" prepopulation you can also add the parameters to your embed code. This is helpful e.g. to set default values or if you don't want the parameters to appear in the URL.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script type=\\\"text/javascript\\\" src=\\\"https://secure.fundraisingbox.com/app/paymentJS?hash={your_form_hash}&amount=12.34&interval_fix=6&fb_item_id=789\\\"></script>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Use session for prepopulation\"\n}\n[/block]\nAfter you created a session with the [Session-API](doc:session-api-introduction) you can append the session hash to prepopulate the the form. Use the parameter \"fbSessionHash\" to do this.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"http://www.myorga.com/donate.html?fbSessionHash={your_session_hash}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Donation box example\"\n}\n[/block]\nPlace this donation box widget on your site. If the user fills out the amount and clicks „donate now“, he/she is automatically forwarded to the corresponding donation form. All details from the donation box are already prepopulated.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<input id=\\\"amount\\\" />\\n<select id=\\\"interval\\\">\\n  <option value=\\\"1\\\">monthly</option>\\n  <option value=\\\"0\\\">once</option>\\n</select>\\n<input type=\\\"submit\\\" value=\\\"donate now\\\" onclick=\\\"processFormData(); return false;\\\" />\\n\\n<script type=\\\"text/javascript\\\">\\nfunction processFormData() \\n{\\n  var embedUrl = 'http://www.myembedurl.com/donate'; // url to your form\\n  var amount_element \\t= document.getElementById('amount');\\n  var interval_element = document.getElementById('interval');\\n  var interval = interval_element.value;\\n  var amount = amount_element.value;\\n  if(amount == '')\\n  {\\n    alert(\\\"Please enter an amount.\\\");\\n  } \\n  else\\n  {\\n    location.href = embedUrl+'?amount='+amount+'&interval='+interval;\\n  }\\n}\\n</script>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"form-prepopulation-api-examples","type":"basic","title":"Examples"}
[block:api-header] { "type": "basic", "title": "Append parameters to your URL" } [/block] For example your URL to your donation form is: http://www.myorga.com/donate.html so you can just append the parameters to your URL. - pro: this is the most easiest way - con: the parameters are visible to the user, so of course these can be manipulated in the URL [block:code] { "codes": [ { "code": "http://www.myorga.com/donate.html?amount=12.34&interval_fix=6&fb_item_id=789", "language": "text" } ] } [/block] [block:api-header] { "type": "basic", "title": "Append parameters to your Javascript-Embed-Code" } [/block] If you want to do a "hidden" prepopulation you can also add the parameters to your embed code. This is helpful e.g. to set default values or if you don't want the parameters to appear in the URL. [block:code] { "codes": [ { "code": "<script type=\"text/javascript\" src=\"https://secure.fundraisingbox.com/app/paymentJS?hash={your_form_hash}&amount=12.34&interval_fix=6&fb_item_id=789\"></script>", "language": "html" } ] } [/block] [block:api-header] { "type": "basic", "title": "Use session for prepopulation" } [/block] After you created a session with the [Session-API](doc:session-api-introduction) you can append the session hash to prepopulate the the form. Use the parameter "fbSessionHash" to do this. [block:code] { "codes": [ { "code": "http://www.myorga.com/donate.html?fbSessionHash={your_session_hash}", "language": "text" } ] } [/block] [block:api-header] { "type": "basic", "title": "Donation box example" } [/block] Place this donation box widget on your site. If the user fills out the amount and clicks „donate now“, he/she is automatically forwarded to the corresponding donation form. All details from the donation box are already prepopulated. [block:code] { "codes": [ { "code": "<input id=\"amount\" />\n<select id=\"interval\">\n <option value=\"1\">monthly</option>\n <option value=\"0\">once</option>\n</select>\n<input type=\"submit\" value=\"donate now\" onclick=\"processFormData(); return false;\" />\n\n<script type=\"text/javascript\">\nfunction processFormData() \n{\n var embedUrl = 'http://www.myembedurl.com/donate'; // url to your form\n var amount_element \t= document.getElementById('amount');\n var interval_element = document.getElementById('interval');\n var interval = interval_element.value;\n var amount = amount_element.value;\n if(amount == '')\n {\n alert(\"Please enter an amount.\");\n } \n else\n {\n location.href = embedUrl+'?amount='+amount+'&interval='+interval;\n }\n}\n</script>", "language": "html" } ] } [/block]