Forum Moderators: open

Message Too Old, No Replies

Updating multiple fields using form

Need a heads up on what to do

         

bateman_ap

9:46 am on Aug 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, I am trying to create a admin interface in ASP to update some records in my SQL database. At the moment the form is like:

UID Name Status
242 Bob Open
265 Charles Closed
266 Jane Cancelled

The Status line has dropdown lists with 3 options in it, open, closed and cancelled which relate to 0, 1 and 2 in the database.

Now what I want to do is be able to change all the statuses, have a submit button at the bottom and when that is clicked update the records in the database with the new status code. However I don't know how to differenterate between them.

Anyone got any ideas?

aspdaddy

7:20 pm on Aug 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this:
strSQL="Update tbl set status="& Request("Status")&" where UID="& Request("UID")

sullen

7:50 pm on Aug 24, 2004 (gmt 0)

10+ Year Member



ASPDaddy - I think the problem is the fact that there are 3 UIDs on the page.

In a situation like this, I always add a number to each row when writing the page (so the form fields are UID_1, Name_1, Status_1, then UID_2 etc). Also add a form field called something like "MaxID" which contains the highest number you got to.

Then you can do something like this

for i = 1 to request("MaxID")
sqlstr = sqlstr & "UPDATE tble SET STATUS='"&request("Status_"&i)&"' WHERE UID ="&request("UID_"&i)&";"
next

bateman_ap

9:44 pm on Aug 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks sullen, good idea. I'll give it a go

bateman_ap

2:21 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just trying to get this to work, however how do I pass the UID value to the query being that only the status is a drop down menu, the UID value is just shown as text

Mr_Brutal

2:23 pm on Aug 25, 2004 (gmt 0)

10+ Year Member



Hi,

Put the UID in a hidden field in the form.

<input name="UID_1" type="hidden" value="<%=UID%>" />

HTH