So I think I'm in some kind of tunnel-vision right now.
I have to maintain a very basic application (HTML + ASP). In this application, there is a small table with some values:
<table>
<tr>
<td>Customer-ID</td>
</tr>
<tr>
<td>Waregroup</td>
</tr>
<tr>
<td>Some other ID</td>
</tr>
<tr>
<td>[edit]</td>
</tr>
<tr>
<td>[delete]</td>
</tr>
<tr>
<td>[checkbox for deletion]</td>
</tr>
</table>
It looks like this, to make it more visual (excluded the rows with data, they are not needed for this):
Now, the delete
-function just doesn't take simply the customer-id (KD Nr.), it takes several more arguments, which are provided in a link. For example, this here:
someSite.com?sid=123456&gkid=133&kdid=9043168&wws=9&del=1
Some of the values are taken from the QueryString, other from a ResultSet from a SQL-Query.
Now I had to extend this application and add a checkbox to bulk-deletion. This wasn't a problem at all, but now I'm kinda stuck on how to get the values which are required for the deletion, when I can basically just use 1 value in each checkbox. I thought about using hidden inputs, but then I have no idea how to determine, which "rows" should be deleted and which not:
This is the addtion I made:
<td>
<input type="checkbox" name="deletebox[]" value="0">
<input type="hidden" name="sid" value="<%=Request.QueryString("sid")%>">
<input type="hidden" name="gkid" value="<%=Request.QueryString("gkid")%>">
<input type="hidden" name="kdid" value="<%=rs("ka_kdnr")%>">
<input type="hidden" name="wws" value="<%=rs("ka_sysid")%>">
</td>
My idea is to loop through every checked checkbox, take the values from the hidden fields and run my deletion-script in a loop.
Any lead on how to do so? Can I simply iterate over all checked checkboxes and request
for the current value of the hidden fields?
I basically just need the gkid and the gkkid for the stored procedure to work.
If you submit a form which contains multiple instances of the same form variable then that the value of that variable in the Request object will appear as a comma separated array. In other words if your form contains the following:
<input type="checkbox" name="gkid" value="25">
<input type="checkbox" name="gkid" value="50">
<input type="checkbox" name="gkid" value="75">
Then Request("gkid")
will display a value of "25,50,75" if you check all of them. You can then split your array as follows.
For i = 1 to Request("gkid").Count
Response.write Request("gkid")(i) & "<br>" & vbcrlf
Next
I'm going to assume that you can take it from there and adapt the above to use Request.Form("gkid")(i)
and apply logic inside the loop with code which calls your stored procedure.
Your question mentions a variable called "gkkid". I can't see where that comes from. If I could I might be able to improve on this answer.