PDA

Click to See Complete Forum and Search --> : ASP Script problem


lenin
May 23rd, 2000, 03:35 AM
Hi,
another question from me ( sorry two today ). I have a couple of questions, but will explain what I am trying to do first.

I am trying to create a number of text boxes and populate them with the value from a field in a recordset I have returned from a query request.
If the recordset field has a particular name I create a text box, if not I just print the value: code below:

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
response.write "<tr><td></td><td></td><td></td><td></td><td><b><font face='Arial'> Total Cost: " & (Total/100) & "p</font></b></td></tr>"
response.write "</TABLE>"

This creates the text boxes, with correct values in them.

Now when a button is pressed I want to check the values in the text boxes, I use:

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

This doesn't work ( not really surprising ), but I would like to know how do I get the values from the text boxes, and have I created the text boxes properly, i.e. are they actually called "quantity1". "quantity2"..."quantityn"

Sorry for convolution.

Lenin.

Any help appreciated.

Mark Sreeves
May 23rd, 2000, 03:07 PM
Here goes!

Your code actually looks pretty good.

I think you need to request num again


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

lenin
May 23rd, 2000, 03:21 PM
Mark,
thnaks for the reply, I will hjave a go and let you know.

again thanks.

Lenin