Need to loop thru form elements

J

Jeremy Langworthy

Hi

I have a dynamicly generated form (well the elements are at least)
that looks something like this:

while( not end of returned records):

<input name="plan_id[]" type="checkbox" id="" value="<?=
$row_plans->planid ?>">

<input name="num_of_pockets[<?= $row_plans->planid ?>]"
type="text" id="num_of_pockets[]" value="<?=
$row_plans->num_of_pockets ?>" size="5" >

endwhile;

Basically it loops thru the table and creates a row of fields in the
form that use the array identifiers '[]' so that I can loop thru them
with PHP when the page is submitted.

The key for each array element is the id of the row from the database.
So checkbox[] (with value "1") and cost[1] are on the same line in the
form. The next line may not necessarily have cost[2] in it, it may be
cost[3] or [4], depending the id from the database.

Is there some way I can loop thru these form elements in javascript?
Does Javascript store them in an array like PHP does?

Any help gladly appreciated.
 
S

steve stevo

yep it sure does..

document.formname.elements

and interate through the elements
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top