PDA

Click to See Complete Forum and Search --> : Form collection


dvst8
Aug 23rd, 2000, 04:20 PM
I have a form whose number of hidden fields grows dynamically. I employ a naming convention such as <itemName>_Number for the names of the hidden fields.

Here's an example of part of a form:

<input type="hidden" name="itemNum_4">
<input type="hidden" name="desc_4">
<input type="hidden" name="quantity_4">
<input type="hidden" name="issue_4">
<input type="hidden" name="unit_4">

<input type="hidden" name="itemNum_5">
<input type="hidden" name="desc_5">
<input type="hidden" name="quantity_5">
<input type="hidden" name="issue_5">
<input type="hidden" name="unit_5">

<input type="hidden" name="itemNum_6">
<input type="hidden" name="desc_6">
<input type="hidden" name="quantity_6">
<input type="hidden" name="issue_6">
<input type="hidden" name="unit_6">



My problem is how to process this form??

I'm not quite sure how to loop through the Form collection to get at all these fields for which I don't know the exact name. Once I get the field name, I can parse it and determine how to procede.

I think this is probably fairly simple, but all the form processing I have done thus far involved only forms for which I knew exactly which fields were in the form. Variable length forms seem a bit tougher to tackle.

Please let me know.

dvst8



[Edited by dvst8 on 08-23-2000 at 05:24 PM]

Ianpbaker
Aug 24th, 2000, 02:57 AM
are you using asp to process the form ?

Ian

Njoannides
Aug 24th, 2000, 04:27 AM
Yon can do like that if you use vbscript:

<%Dim i

For i = 1 To NumberofItems%>
<input type="hidden" name="itemNum_" & <%=CStr(i)%>>
<input type="hidden" name="desc_" & <%=CStr(i)%>
<input type="hidden" name="quantity_" & <%=CStr(i)%>>
<input type="hidden" name="issue_" & <%=CStr(i)%>>
<input type="hidden" name="unit_" & <%=CStr(i)%>>
<%Next%>



Nicolas Joannidès
C, C++, Visual Basic, ASP
njoannides@ares.fr

Ianpbaker
Aug 24th, 2000, 04:38 AM
If you are using asp to get the field names use the following


set fieldsfromform = request.form

for each item in fieldsfromform
response.write "The name of the field is " & item & "<br>"

response.write "The value of the field is " & fieldsfromform(item) & "<br>"
next



Hope this helps

ian

dvst8
Aug 24th, 2000, 10:53 AM
Thanks guys. that's exactly what i needed.

d