jeudi 16 août 2018

Bulk delete with checkboxes and additional values

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):

enter image description here

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.




Aucun commentaire:

Enregistrer un commentaire