Results 1 to 5 of 5

Thread: Form collection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    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:
    Code:
                    <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]
    Secret to long life:
    Keep breathing as long as possible.

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    are you using asp to process the form ?

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3
    New Member
    Join Date
    Aug 2000
    Location
    France
    Posts
    7
    Yon can do like that if you use vbscript:
    Code:
    <%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
    [email protected]



  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    If you are using asp to get the field names use the following

    Code:
    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
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    Thanks guys. that's exactly what i needed.

    d
    Secret to long life:
    Keep breathing as long as possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width