abajan

populateAnAddressFieldWithEntriesFormAnother

Sep 16th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. The following script populates one field (the mailing address) in a form with the entries of another (the physical address) if a certain selection is made in a radio button field and removes the entries from the mailing address if the other radio button is chosen.
  2.  
  3. Screenshot:
  4. http://cms.interlogy.com/uploads/image_upload/image_upload/global/3155_populate2ndAddressWithEntriesIn1stAddress.png
  5.  
  6.  
  7. <script type="text/javascript">
  8. function data_copy()
  9. {
  10. if(document.form_12572835007.q30_addressBelow[0].checked){
  11. document.form_12572835007.input_9_addr_line1.value=document.form_12572835007.input_8_addr_line1.value;
  12. document.form_12572835007.input_9_addr_line2.value=document.form_12572835007.input_8_addr_line2.value;
  13. document.form_12572835007.input_9_city.value=document.form_12572835007.input_8_city.value;
  14. document.form_12572835007.input_9_state.value=document.form_12572835007.input_8_state.value;
  15. document.form_12572835007.input_9_postal.value=document.form_12572835007.input_8_postal.value;
  16. document.form_12572835007.input_9_country.value=document.form_12572835007.input_8_country.value;
  17. }else{
  18. document.form_12572835007.input_9_addr_line1.value="";
  19. document.form_12572835007.input_9_addr_line2.value="";
  20. document.form_12572835007.input_9_city.value="";
  21. document.form_12572835007.input_9_state.value="";
  22. document.form_12572835007.input_9_postal.value="";
  23. document.form_12572835007.input_9_country.value="";
  24. }
  25. }
  26. </script>
  27.  
  28.  
  29. How to Use
  30.  
  31. 1. Create the form and include three fields: 2 Address + 1 Radio Button (See screenshot at link above)
  32.  
  33. 2. Set the form to load with neither choice in the radio button field selected
  34.  
  35. Screenshot:
  36. http://cms.interlogy.com/uploads/image_upload/image_upload/global/3156_nothingSelectedByDefault.png
  37.  
  38. 3. Complete the construction of the form and save it
  39.  
  40. 4. While on the Setup & Embed tab, click Embed Form > Source > copy source to clipboard
  41.  
  42. 5. Paste what was copied in Step 4 into the source of your web page at the position where you would like the form to appear
  43.  
  44. 6. Copy the script above and paste it into the same page in which the form was pasted, near the end of the page, just before the </body> tag
  45.  
  46. 7. Edit the script in the following manner:
  47. a) Replace all instances of "12572835007" with the ID of your form. (Search the source for the string name="form_ and you will find the form's ID after the underscore)
  48. b) Replace "q30_addressBelow" with the value of the "name" attribute in the input tags of the radio button field
  49. c) Include an onClick event in each input of the radio button field
  50.  
  51. Re: 7b and 7c, see to the following screenshot:
  52. http://cms.interlogy.com/uploads/image_upload/image_upload/global/3157_matchingValueOfNameAttributesPlusMatchingOnClickEventInRadioButtonInputs.png
  53.  
  54. 8. In the form's source, take note of the number in the IDs of each address field. For each input in a given address field, the digit or number in the ID matches that in the ID of the entire field.
  55.  
  56. Screenshot:
  57. http://cms.interlogy.com/uploads/image_upload/image_upload/global/3193_theDigitOrNumberInTheIdOfEachInputMatchesThatContainedInTheIdOfTheEntireField.png
  58.  
  59.  
  60. 9. Edit the numbers in the script to match the IDs of the form's relevant address fields.
  61.  
  62. Screenshot:
  63. http://cms.interlogy.com/uploads/image_upload/image_upload/global/3161_editTheDigitsOrNumbersOfTheIDsInTheScriptToMatchTheTheIDsOfTheRelevantAddressFieldsInTheForm.png
  64.  
  65. 10. Save the changes made to your web page
Advertisement
Add Comment
Please, Sign In to add comment