Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  7] [ 1]  / answers: 1 / hits: 38847  / 13 Years ago, tue, november 8, 2011, 12:00:00

How can I copy the form field values from one set of fields to another using javascript.



The idea here is to have a 'use shipping/billing address' type of button that copies the user information from one block of fields to another identical set of fields.



Right now, I call an action upon click of a button to execute the following javascript:



this.field1.value = this.field2.value;


However that action yields an 'undefined' error in the debugger.


More From » pdf

 Answers
27

For posterity, this is the solution to the problem:



getField(field2).value = getField(field1).valueAsString;


Also, note that field2 is set to field1 so the order is backwards.


[#89236] Monday, November 7, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;