Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy form values 1

Status
Not open for further replies.

travmak

Programmer
Apr 26, 2002
133
US
I have a form that i want to copy the values to another form. the field names are the same, just the form name is different. would this work in an onclick function? I'm a wee bit worried about the syntax. I haven't had the chance to TS it yet because i'm working on 47 differrent things. thanks

for (var indexnum = 0; indexnum < formname.length; indexnum++){
nameOfFieldToCopy = formname[indexnum].name
formname2.nameOfFieldToCopy.value = formname.nameOfFieldToCopy.value;
}
 
var elementLen = document.frm1.elements.length
var eleIndex;

for (eleIndex=0; eleIndex<elementLen; eleIndex++){
document.frm2.elements[eleIndex].value= document.frm1elements[eleIndex].value }
 
sorry, forgot the dot inbetween frm1 and elements:

for (eleIndex=0; eleIndex<elementLen; eleIndex++){
document.frm2.elements[eleIndex].value= document.frm1.elements[eleIndex].value }
 
hmm, well actualy That's good code to know, however I need to do it by name. The index number is not going to be the same for the form. One form has almost 100 fields that is getting passed to page to page, and each page has about 12 or so fields and it is adding values to the form while keeping the values of the previous form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top