How do you populate billing address with information from the same page with a button?

This is an asp page. Using html, javascript and asp.
On this page I collect address information, Street, City, State, Zip. Later down the page I have where you put in your credit card information. Does anyone have sample code where I can click a button that says 'Same as Personal Information' and it would populate card Street, City, state, Zip with the information they already entered?

Also the cardname is one field, I would need it to combine the first  and last names from the earlier up the page.


<!-- Name from the personal info -->
<tr valign="bottom">
<td class="bluetxt">First Name*</td>
<td><input name="FirstName" value="<%Response.Write request.form("FirstName")%>" type="text" id="Text3"></td>
</tr>
 
<tr valign="bottom">
<td class="bluetxt">Last Name*</td>
<td><input name="LastName" value="<%Response.Write request.form("LastName")%>" type="text" id="Text4"></td>
</tr>
 
<!-- Street and city from the personal info -->
<tr valign="bottom">
<td><nobr><font color=""#ff0000"">Street* </font></nobr>
</td>
<td valign="bottom" colspan="2">
<input name="Address1" value="<%Response.Write request.form("Address1")%>" type="text" id="Text12" size="30">
</td>
 
<tr valign="bottom">
<td><font color=""#ff0000"">City*</font></td>
<td colspan="2">
<input name="AddressCity" value="<%Response.Write request.form("AddressCity")%>" type="text" id="Text15" size="30"></td>
</tr>
 
 
<!-- Name, CardStreet and City from later in the page -->
<TR>
<td width="126" height="30">
<b>Name on card:</b>
</td>
<td height="30">
<input type="text" value="" name="cardName" size="20" maxlength=20>
</td>
</TR>
<TR>
<td width="126" height="30">
<b>Street:</b>
</td>
<td height="30">
<input type="text" value="" name="CardStreet" size="15" maxlength=50>
</td>
</TR>
							
<TR>
<td width="126" height="30">
<b>City:</b>
</td>
<td height="30">
<input type="text" value="" name="CardCity" size="15" maxlength=50>
</td>
</TR>

Open in new window

seahawk9Asked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
try something like the attached script. You just need to add whiever fields you need to "transfer" from the top to the bottom:
<script>
function transferInfo(o)
{
	if( o.checked)
	{
		var f = o.form;
		f.CardStreet.value = f.Address1.value;
		f.CardCity.value = f.AddressCity.value;
		
	}
}
</script>

Open in new window

0
 
hieloCommented:
BTW, the checkbox would be:
<input type="checkbox" name="billing" value="sameaspersonal" onclick="transferInfo(this)"/>Same as personal info

Open in new window

0
 
hieloCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.