Copy information from one part of a form to another

M

Mike

I have a form that has a place for "Customer" and "CO-Customer" information.

I want to put a button by the CO-Customer section that will copy the Address
information from the Customer.

Do I have that button be a Submit button that posts the information back to
the form and the writes it?

Mike
 
R

Ray at

Posting back is an option, but I would say that client-side code is probably
more commonly used. Either that or just use a checkbox that lets the user
select "same address" or something and leave it at that.

Ray at home
 
B

Bhaskardeep Khaund

Hi,

You could do this easily using a JavaScript function, on the client side. Just on click of the button fire the JS function which copies the content from one form field to another. If u need any more help tell me, i can write u the code.

Regards,
Bhaskardeep Khaund
 
J

Jeff Cochran

I have a form that has a place for "Customer" and "CO-Customer" information.

I want to put a button by the CO-Customer section that will copy the Address
information from the Customer.

Do I have that button be a Submit button that posts the information back to
the form and the writes it?

Don't go server side for this. Check a Javascript group, there's
plenty of code snippets for this type of thing. An alternate would be
a DHTML setup, with hidden/unhidden code or the like.

Jeff
 
M

Mike

Bhaskardeep,

I would not even know where to start doing this.

It would be great if you could offer me some
more help.

Mike
Hi,

You could do this easily using a JavaScript function, on the client side. Just on click of the button fire the JS function which copies the content from one form field to another. If u need any more help tell me, i can write u the code.

Regards,
Bhaskardeep Khaund
 
C

Chris Hohmann

Mike said:
I have a form that has a place for "Customer" and "CO-Customer" information.

I want to put a button by the CO-Customer section that will copy the Address
information from the Customer.

Do I have that button be a Submit button that posts the information back to
the form and the writes it?

Mike

How about allowing the user to leave the CO-Customer address blank? This
is a common implementation on commerce sites. Billing address is
required (for credit card authentication) and you only need to provide a
shipping address if it's different from your billing address. Just a
thought. YMMV

-Chris Hohmann
 
B

Bhaskardeep Khaund

HI,

Do like this:-

<html>
<head>
<title>New Page 1</title>
<Script Language="JavaScript">
function fnCopy(){
document.myform.box2.value = document.myform.box1.value;
}
</Script>
</head>
<body>
<form name="myform" mthod="post">
<p><textarea rows="2" name="box1" cols="20"></textarea></p>
<p><input type="button" value="Button" name="Copy Text from Box1 to Box2" onClick="javascript:fnCopy()"></p>
<p><textarea rows="2" name="box2" cols="20"></textarea></p>
</form>
</body>
</html>
Hope this Helps

Bhaskardep Khaund
 
M

Mike

It workes GREAT! Thanks.
HI,

Do like this:-

<html>
<head>
<title>New Page 1</title>
<Script Language="JavaScript">
function fnCopy(){
document.myform.box2.value = document.myform.box1.value;
}
</Script>
</head>
<body>
<form name="myform" mthod="post">
<p><textarea rows="2" name="box1" cols="20"></textarea></p>
<p><input type="button" value="Button" name="Copy Text from Box1 to Box2" onClick="javascript:fnCopy()"></p>
<p><textarea rows="2" name="box2" cols="20"></textarea></p>
</form>
</body>
</html>
Hope this Helps

Bhaskardep Khaund
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top