467,134 Members | 1,068 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

Problem with dynamic form

100+
Hi there.

I have a problem in to recover the values of a dynamic form.

The form is this:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * "
  2. strSQL = strSQL & " FROM " 
  3. strSQL = strSQL & " TBL " 
  4. strSQL = strSQL & " ORDER " 
  5. strSQL = strSQL & " BY DESCR ASC "
  6.  
  7. Set Rs = Server.CreateObject("ADODB.Recordset")
  8. Rs.Open strSQL, objconn
  9.  
  10. If Not Rs.EOF Then
  11.  
  12. strID = 0
  13.  
  14. Do while NOT Rs.EOF
  15. strID = strID + 1 
  16.  
  17. Response.write "<td><input type=""text"" name=""descr_<%=strID%>"" Value="& Rs("DESCR") &"></td>"
  18.  
  19. Response.write "<td><input type=""text"" name=""name_<%=strID%>"" Value="& Rs("NAME") &"></td>"
  20.  
  21. Rs.MoveNext
  22. Loop
  23. end if
  24.  
  25. Rs.Close
  26. set Rs = nothing
  27.  
  28. objconn.Close
  29. set objconn = nothing
  30.  
  31. %>
  32.  
The variable strID is automatically assigned and progressively to according to of the fields "descr" and the fields "name" extracts in the cycle from the query; then descr is variable: from a minimum = 1 to a maximum of N.

I recover value "descr" and "name":

Expand|Select|Wrap|Line Numbers
  1. for each item in request.form
  2.    response.write item & " = " & request.form(item) & "<br />"
  3. next
Now I would like to insert the data coming from the form in a query.
Number and name from dynamic form it is variable.

Can you help?
Thanks
Nov 3 '07 #1
  • viewed: 1186
Share:
2 Replies
jhardman
Expert 2GB
Viki,

Instead of using an "INSERT" statement, I would recommend using a recordset like you uesd to open it in the first place, something like this:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * "
  2. strSQL = strSQL & " FROM " 
  3. strSQL = strSQL & " TBL " 
  4. strSQL = strSQL & " ORDER " 
  5. strSQL = strSQL & " BY DESCR ASC "
  6.  
  7. Set Rs = Server.CreateObject("ADODB.Recordset")
  8. Rs.Open strSQL, objconn
  9.  
  10. for i = 1 to n 'you will need to set these numbers
  11. Rs.addNew
  12. rs("desc") = request.form("desc" & i)
  13. rs("name") = request.form("name" & i)
  14. Rs.update
  15. next
  16.  
Is this the kind of thing you are looking for?

Jared
Nov 5 '07 #2
100+
OK !

Many thanks !!!

Regards,
Viki
Nov 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Nathan Bloomfield | last post: by
3 posts views Thread by CAD Fiend | last post: by
reply views Thread by Venus | last post: by
1 post views Thread by dawg1998 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.