client side - javascript variables -


hello wondering why firbug stating nan when these inputs have information entered.

    for(i=1;i<8;i++){ var field = document.contactform.field + i.value; console.log(field);      } 

i trying iterate through field1, field2 field3 .... field7.

i assume have number of fields field0 ... field8.

for that, need use different notation:

var field = document.contactform[field + i].value; 

by way, while forms can accessed name way show, more preferable approach document.forms array:

 var field = document.forms["contactform"]["field" + i].value; 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -