close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Auto Fill form fields | similar to "use billing for shipping address" function

Thread began 3/03/2010 6:59 pm by ruth265305 | Last modified 3/04/2010 12:17 pm by ruth265305 | 5042 views | 7 replies |

ruth265305

Auto Fill form fields | similar to "use billing for shipping address" function

Good day:
I have a registration form that has fields for two registrants. We need address info on both registrants, often though the second registrant is a spouse, so I would like a check box or feature that would "auto-fill" the second registrant's address info with what was input for the first registrant so they wouldn't have to retype it unless it is different.

registrationForm.php

Sign in to reply to this post

Jason ByrnesWebAssist

You will need to hand code the Javascript to accomplish this.

see the following post for a link to a good example:
showpost.php?p=44775&postcount=2

Sign in to reply to this post

ruth265305

javascript

thanks Jason. I will give it a try.

Sign in to reply to this post

ruth265305

Javascript is throwing errors

Hi Jason:

I needed to adapt the script to work with my form and it's just not working. I'm not very fluent in javascript, so I hope someone can look at this and tell me why it's throwing errors. Thanks!

<SCRIPT LANGUAGE="JavaScript">
// <!--
function shipsame(WADAInsertForm){

if(WADAInsertForm.sameasbilling.checked){

WADAInsertForm.address.value = WADAInsertForm.second_address.value;
WADAInsertForm.address2.value = WADAInsertForm.second_address2.value;
WADAInsertForm.city.value = WADAInsertForm.second_city.value;
WADAInsertForm.state.value = WADAInsertForm.second_state.value;
WADAInsertForm.zip.value = WADAInsertForm.second_zip.value;
}
}
else{
WADAInsertForm.address.value = "";
WADAInsertForm.address2.value = "";
WADAInsertForm.city.value = "";
WADAInsertForm.state.value = "";
WADAInsertForm.zip.value = "";
}
//-->
</script>


<input type="checkbox" name="sameasbilling" value="checkbox"
onClick="shipsame(this.WADAInsertForm);">

Sign in to reply to this post

Jason ByrnesWebAssist

change the script to:
<SCRIPT LANGUAGE="JavaScript">
// <!--
function shipsame(form){

if(form.sameasbilling.checked){

form.address.value = form.second_address.value;
form.address2.value = form.second_address2.value;
form.city.value = form.second_city.value;
form.state.value = form.second_state.value;
form.zip.value = form.second_zip.value;
}
}
else{
form.address.value = "";
form.address2.value = "";
form.city.value = "";
form.state.value = "";
form.zip.value = "";
}
//-->
</script>

Sign in to reply to this post

ruth265305

javascript updated and still not working

Hi Jason:
You've been so responsive, and I feel bad to report that the script still isn't working on the page. I copied and pasted the code and checked it on IE and Firefox.

Sign in to reply to this post

Jason ByrnesWebAssist

there are some errors in the script syntax and the form referances are backwards, try this instead:

<script type="text/javascript">

<!--
function shipsame(form){

if(form.sameasbilling.checked){

form.second_address.value = form.address.value;
form.second_address2.value = form.address2.value;
form.second_city.value = form.city.value;
form.second_state.value = form.state.value;
form.second_zip.value = form.zip.value;

}
else{
form.second_address.value = "";
form.second_address2.value = "";
form.second_city.value = "";
form.second_state.value = "";
form.second_zip.value = "";
}
}
//-->
</script>
Sign in to reply to this post

ruth265305

auto fill working

Hi Jason:
The last code did the trick perfectly. Thank you so much for your assistance.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...