PDA

Click to See Complete Forum and Search --> : Reading Form Content:


lenin
Jul 2nd, 2000, 11:00 AM
Hi,
some time back I send the following in:
-----------------------------------------------------------

Hi,
Is anyone aware of how to request the name of each object on a HTML form?

I am dynamically creating textboxes based on the name of a field returned from an SQL query, however, when I try to access the contents of the text boxes with the name I think I gave them, it returns nothing despite the fact they are populated. Code to create the text boxes, with values below.

dim num
num = 1
do while not records.eof
for each fld in records.fields
response.write "<TD align='center' >"
if fld.name = "quantity" then
response.write "<input type = 'text' size='5' name='quantity" & num & "' value = " & fld.value & ">"
num = num + 1
else
response.write "<font face='Arial'>" & fld.value & "</font>"
end if
response.write "</TD>"
next
total = total + records("Total")
response.write "<tr>"
records.movenext
loop


Any help appreciated.

Lenin

-----------------------------------------------------------

What I don't understand is this:

I have a button:

if Request("Update_Values") = "Update Basket Details" Then
for i = 1 to num - 1
x = Request.Form("quantity" & i)
response.write "X is :" & x
next
end if

which when pressed I want to write the contents of the dynamically created text boxes to the brwser. However this displays no values!

Can someone point me in the right direction. I really can't see a lot wrong with this.

Thnaks in advance.

Lenin

Clunietp
Jul 2nd, 2000, 12:09 PM
where are you writing your <FORM> tag?

lenin
Jul 3rd, 2000, 01:22 AM
If you mean do I have

< form ... mthod = "post" >

Then yes.

Thnaks

Lenin

Clunietp
Jul 3rd, 2000, 11:13 AM
where are you getting your NUM variable when you are requesting your form back?

If you accumulate NUM in your first loop, I'm assuming your page would then end (and all your variables would be destroyed). On the second time around (the form reading), you are expecting the NUM variable to still hold the number of fields that you have. This won't happen, because NUM has been previously destroyed.

If you want a way around that, use a hidden form variable with the count (that you populate after the first loop), or maybe a cookie, or maybe an EVIL session variable