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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting form name from document.forms[]

Status
Not open for further replies.

JeeEiych

IS-IT--Management
Aug 22, 2001
7
I have several forms in a page. I want to access a repeating field from those forms but I want to avoid one particular form. I tried to access the name but I can't. This is how I tried it..

for (var iForm = 0; iForm < document.forms.length; iForm++) {
if ((document.forms[iForm].name != "FormA"){
iCalc = document.forms[iForm].FieldA.value * x;
document.forms[iForm].FieldB.value = iCalc;
}
}

Not all form have FieldA that''s why I want to avoid it.
 
[tt]for (var iForm = 0; iForm < document.forms.length; iForm++) {
if [highlight]([/highlight]document.forms[iForm].name != "FormA" [blue]&& document.forms[iForm].FieldA && document.forms[iForm].FieldB[/blue]){
//whatever x is, it is expected to be a number, such as
//var x=10;
var iCalc = [blue]parseFloat([/blue]document.forms[iForm].FieldA.value[blue])[/blue] * x;
document.forms[iForm].FieldB.value = iCalc;
}
[highlight]}[/highlight]
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top