Hi,
Have multiple checkboxes on my form that I need to loop through and see which ones are 'checked' - then if the checked ones match an ID in a recordset I want to write 1 to a field.
Have requested the 'x_pxselect' values and written them out so I know that part works ok, but am having issue writing to the RS.
problem is only one record ever gets a 1 in select field - interestingly if I tick both boxes the 'selected' records get switched
hope im makeing sense - long day ;-)
html
asp
Have multiple checkboxes on my form that I need to loop through and see which ones are 'checked' - then if the checked ones match an ID in a recordset I want to write 1 to a field.
Have requested the 'x_pxselect' values and written them out so I know that part works ok, but am having issue writing to the RS.
problem is only one record ever gets a 1 in select field - interestingly if I tick both boxes the 'selected' records get switched
hope im makeing sense - long day ;-)
html
Code:
<input name='x_pxselect' type="checkbox" value="20" checked/>
<input name='x_pxselect' type="checkbox" value="19"/>
asp
Code:
eventstocklinkSQL = "SELECT * FROM eventstocklink "_
& "WHERE eventstocklink.eventid = '" & action.eventid.SessionValue & "' "_
& "AND statusid = 5"
'checked sql and outputs two cars
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = EW_CURSORLOCATION
rs.Open eventstocklinkSQL, conn, 1, 2
'loop through rs to get id
Do while not rs.eof
x_eventstocklinkid = rs("eventstocklinkid")
'loop through checkbox to get id
For Each x_pxselect In Request.Form("x_pxselect")
if x_pxselect = "" then x_pxselect = 0
'response.Write (x_pxselect) & " " & x_eventstocklinkid & " <br>"
'match id of rs to key of checkbox
if CINT(x_pxselect) = x_eventstocklinkid then
'write value
rs("select") = 1
end if
Next
'update rs
rs.update
rs.movenext
loop
'close rs
rs.close
set rs = nothing