954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

calculating dynamic field names


/
=

no1uknow
Newbie Poster
2 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

You need to loop through a series of texboxes, right?

so something like this should work to get the value of your textboxes...

for(i=0; i<document.forms[0].elements.length; i++){
   if(document.forms[0].elements[i].type == 'text')
      var elName = document.forms[0].elements[i].name;
      var elValue = document.forms[0].elements[i].value;
       // Display element name and value
      alert(elName +' = '+ elValue)
   }
}
senexom
Junior Poster in Training
54 posts since Jun 2005
Reputation Points: 11
Solved Threads: 0
 

You need to loop through a series of texboxes, right?

so something like this should work to get the value of your textboxes...

for(i=0; i<document.forms[0].elements.length; i++){
   if(document.forms[0].elements[i].type == 'text')
      var elName = document.forms[0].elements[i].name;
      var elValue = document.forms[0].elements[i].value;
       // Display element name and value
      alert(elName +' = '+ elValue)
   }
}


Hi, thanx for this solution it's near to fix my same problem too...

I have this (php dynamic fields):

<input name="itemID[]" value="<?=$row[id]?>" /><input name="price[]" value="<?=$row[price]?>" /><input name="qty[]" value=""  onFocus="startCalc();" onBlur="stopCalc();" /><input name="subtotal[]" value="" />
accountholder
Newbie Poster
22 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You