473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need to loop thru form elements

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.
Jul 20 '05 #1
1 6232
yep it sure does..

document.formname.elements[i]

and interate through the elements
"Jeremy Langworthy" <gr****@8legs.co.nz> wrote in message
news:c7**************************@posting.google.c om...
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.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Randi | last post by:
Hi is there any other way of writing this function, I am just wondering if there is another way of reading through the array like using a for loop or something. Can you do this using a for loop? ...
3
by: brett | last post by:
Using DOM in IE, how can I loop through FORMs and access FORM elements in a specific form? For example, www.hotmail.com has about 13 forms. I believe the one displayed is dependent on the URL. If...
5
by: Nick Calladine | last post by:
Learning : Loop to list all dropdown box values on a form Can some one point me in the right direction : I have a form which I want to loop through I basically want to get all the selected...
0
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to...
6
by: Ed Jay | last post by:
<disclaimer>New to js.</disclaimer> I have several pages, each with menues comprising checkboxes or radio boxes within the same form. I presently 'brute force' clear the buttons with individual...
6
by: doncee | last post by:
Using a multi select list box to open several records in a pre - defined form. Most of the code that follows is taken from a posting by Alan Browne on his web site. The click routine is supposed...
9
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I tried doing this without any help, but i'm...
2
by: ckerns | last post by:
I have a page with a bunch of drop down boxes. They are named: MonEquipAMWk1 MonEquipPMWk1 thru FriEquipAMWk1 FriEquipPMWk1
5
by: Eric Layman | last post by:
Hi, Many years ago when I first learnt abt web dev in school, I was taught this methodology: <html> blah blabh
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.