I have a form for tracking work progress of each staff. Since one staff can do many tasks at a day. Therefore to save working time, I created checkboxes for task so that i can select and save as multi-records at a time. My code is as below
<td colspan="2">
<%
if rsPdtn_sizeColor.eof then
call displayNotFoundRecord
Else
Do Until rsPdtn_sizeColor.Eof
%>
<div style="width:120px; float:left"><input type="checkbox" name="pdtn_szcl_id" value="<%=rsPdtn_sizeColor.fields.item("pdtn_szcl_id")%>"> <%=rsPdtn_sizeColor.fields.item("pdtn_st_size")%> <%=rsPdtn_sizeColor.fields.item("pdtn_st_color")%></div>
<div style="width:50px; float:left"><input type="text" name="pdtn_qty" value="<%=rsPdtn_sizeColor.fields.item("pdtn_st_qty_est")%>" size="7"></div>
</div>
<div style="clear:both"></div>
<%
rsPdtn_sizeColor.movenext
Loop
End if
rsPdtn_sizeColor.movefirst
%>
</td>
<td><input name="pdtn_note" value="<%=pdtn_note%>" size="39"></td>
However, with this code, only field “pdtn_szcl_id” that can pass only recordset that i checked. I want “pdtn_qty” to do the same as well. So could you please help me on this. Thank you
The problem is that you should not have form elements like input with duplicate names. There are a couple of possible solutions but this is probably the safest.
In your code add the database id to the name of the checkbox and qty textbox, something like this:
Then when you want to retrieve the values you will need to open your recordset again and loop through the rows checking if the checkbox has been checked and getting the value, something like this:
NB. I used Request.Form but if you use form method GET then you should change to Request.QueryString.