Rene
|
| Posted: 07/03/2002, 8:39 AM |
|
Can somebody help me with the proper syntax to copy the value of one input field into another?...
I'm creating a record form in CCS with several columns of input fields. The first column of fields is labled Side1 and the second column is labeled Side2. 90% of the time, whatever a user inputs into the side1 fields they'll also input into the equivalent side2 fields, so I'd like to create a button with a Server Onclick event which copies the value in one set of input fields into another. Basically, copy formname.field1.value to formname.field2. Can anybody offer some guidance?
|
|
|
 |
rbaldwin
|
| Posted: 07/03/2002, 10:23 AM |
|
I think it makes more sense to do it on the client via javascript? This way there is no server/database action till after the value of field2 gets set from the value of field1 and the user can still change field2 before clicking on submit. hope this helps
Rod.
<SCRIPT language=javascript>
function field1OnChange()
{
document.formname.field2.value = document.formname.field1.value
}
</SCRIPT>
....
<Form name=formname>
<input type=text name=field1 onChange="field1OnChange()">
<input type=text name=field2 >
</Form>
|
|
|
 |
Rene
|
| Posted: 07/03/2002, 1:57 PM |
|
Rod, thanks for the suggestion. Stupid question maybe but I'm new to all this stuff and I don't know much about Java. Would you assign the Java script to a client-side on-click event, so that when the user clicked on a button the code would execute on the client? Or... would you place this code at the top of the form and then would Java automatically copy the value in field1 to the field2 as the user typed the values in?
|
|
|
 |
rbaldwin
|
| Posted: 07/04/2002, 8:20 AM |
|
actually java and javascript are two separate things.
I've not done this myself yet but, if you click on field1 in the project explorer, then in the properties window events tab, under client add onChange Action of type "Custom Code". CCs will then display where you need to add my suggestion.
|
|
|
 |
|