473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_po ckets[<?= $row_plans->planid ?>]"
type="text" id="num_of_pock ets[]" value="<?=
$row_plans->num_of_pocke ts ?>" 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 6249
yep it sure does..

document.formna me.elements[i]

and interate through the elements
"Jeremy Langworthy" <gr****@8legs.c o.nz> wrote in message
news:c7******** *************** ***@posting.goo gle.com...
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_po ckets[<?= $row_plans->planid ?>]"
type="text" id="num_of_pock ets[]" value="<?=
$row_plans->num_of_pocke ts ?>" 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
1606
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? Thanks var base = 799; var RAM = ; var HD = ;
3
5192
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 I want to access the submit button of the visible form, which is usually the last one, how is that done? Currently, I look for type=submit using...
5
3457
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 values of the option tag see example below
0
1654
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 this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want...
6
1666
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 scripts for each form, e.g.: function clearLa() { window.document.form1.button1La.checked=false; window.document.form1.button2La.checked=false;...
6
1949
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 to loop thru all of the reports, or in this case records, selected in the list box & display them for previewing or editing. In my situation it only...
9
1597
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 getting nowhere. I want to create an XML schema (XSD) for a dataset/datatable using the XML designer.
2
5059
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
1671
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
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.