copying contents of billing addy to shipping addy

L

libsfan01

Hi all!

Can anyone show me how to use javascript to populate shipping address
form fields with pre-typed payment address details upon checking of a
checkbox next to the obligatory text "click here if the shipping
address is the same as the billling address"? I've looked everywhere
for it but surprizingly have had no luck!
 
D

Dag Sunde

libsfan01 said:
Hi all!

Can anyone show me how to use javascript to populate shipping address
form fields with pre-typed payment address details upon checking of a
checkbox next to the obligatory text "click here if the shipping
address is the same as the billling address"? I've looked everywhere
for it but surprizingly have had no luck!

....
<input type="text" id="billingAddress" />
....
<input type="text" id="shippingAddress" />
....

<script>
....
document.getElementById("shippingAddress").value =
document.getElementById("billingAddress").value;
....
</script>
 
L

Lee

libsfan01 said:
Hi all!

Can anyone show me how to use javascript to populate shipping address
form fields with pre-typed payment address details upon checking of a
checkbox next to the obligatory text "click here if the shipping
address is the same as the billling address"? I've looked everywhere
for it but surprizingly have had no luck!

Find any of the existing forms that do this and look at the source.


--
 
L

libsfan01

Hi Dag

I've tried this and it doesn't work. Is something missing?

"
<head>
<script type="text/javascript">
document.getElementById("delforename").value =
document.getElementById("forename").value;
</script>
</head>

<body>
<form action="" name="" id="form" method="post">
<input type="text" id="forename" />
<input type="text" id="delforename"/>
<input type="submit" name="submit" value="submit" />
</form>
</body>

</html>
"
 
D

Dag Sunde

libsfan01 said:
Hi Dag

I've tried this and it doesn't work. Is something missing?

"
<head>
<script type="text/javascript">
document.getElementById("delforename").value =
document.getElementById("forename").value;
</script>
</head>

Script outside a function in the head section is run immediately,
before your page is rendered. So while the sctipt statements is correct,
there is noting on the page yet to copy to or from...
<body>
<form action="" name="" id="form" method="post">
<input type="text" id="forename" />
<input type="text" id="delforename"/>
<input type="submit" name="submit" value="submit" />
</form>
</body>

</html>
"

Try this:

<head>
<script type="text/javascript">
function copyAddress() {
document.getElementById("delforename").value =
document.getElementById("forename").value;
}
</script>
</head>


<body>
<input name="chkCopy" type="checkbox" value="" onClick="copyAddress();">
<label>Use billing adress</label>

<form action="" name="" id="form" method="post">
<input type="text" id="forename" />
<input type="text" id="delforename"/>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top