Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- Screenshot:
- http://cms.interlogy.com/uploads/image_upload/image_upload/global/3155_populate2ndAddressWithEntriesIn1stAddress.png
- <script type="text/javascript">
- function data_copy()
- {
- if(document.form_12572835007.q30_addressBelow[0].checked){
- document.form_12572835007.input_9_addr_line1.value=document.form_12572835007.input_8_addr_line1.value;
- document.form_12572835007.input_9_addr_line2.value=document.form_12572835007.input_8_addr_line2.value;
- document.form_12572835007.input_9_city.value=document.form_12572835007.input_8_city.value;
- document.form_12572835007.input_9_state.value=document.form_12572835007.input_8_state.value;
- document.form_12572835007.input_9_postal.value=document.form_12572835007.input_8_postal.value;
- document.form_12572835007.input_9_country.value=document.form_12572835007.input_8_country.value;
- }else{
- document.form_12572835007.input_9_addr_line1.value="";
- document.form_12572835007.input_9_addr_line2.value="";
- document.form_12572835007.input_9_city.value="";
- document.form_12572835007.input_9_state.value="";
- document.form_12572835007.input_9_postal.value="";
- document.form_12572835007.input_9_country.value="";
- }
- }
- </script>
- How to Use
- 1. Create the form and include three fields: 2 Address + 1 Radio Button (See screenshot at link above)
- 2. Set the form to load with neither choice in the radio button field selected
- Screenshot:
- http://cms.interlogy.com/uploads/image_upload/image_upload/global/3156_nothingSelectedByDefault.png
- 3. Complete the construction of the form and save it
- 4. While on the Setup & Embed tab, click Embed Form > Source > copy source to clipboard
- 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
- 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
- 7. Edit the script in the following manner:
- 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)
- b) Replace "q30_addressBelow" with the value of the "name" attribute in the input tags of the radio button field
- c) Include an onClick event in each input of the radio button field
- Re: 7b and 7c, see to the following screenshot:
- http://cms.interlogy.com/uploads/image_upload/image_upload/global/3157_matchingValueOfNameAttributesPlusMatchingOnClickEventInRadioButtonInputs.png
- 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.
- Screenshot:
- http://cms.interlogy.com/uploads/image_upload/image_upload/global/3193_theDigitOrNumberInTheIdOfEachInputMatchesThatContainedInTheIdOfTheEntireField.png
- 9. Edit the numbers in the script to match the IDs of the form's relevant address fields.
- Screenshot:
- http://cms.interlogy.com/uploads/image_upload/image_upload/global/3161_editTheDigitsOrNumbersOfTheIDsInTheScriptToMatchTheTheIDsOfTheRelevantAddressFieldsInTheForm.png
- 10. Save the changes made to your web page
Advertisement
Add Comment
Please, Sign In to add comment