SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Grabbing values from checkboxes - HELP!

    Hello,

    I've been asked to do a small project in classic asp, which I haven't touched on for a while so was wondering if someone could provide a little assistance with a problem I'm having.

    Basically, I am trying to grab two values from checkboxes that are selected by the user at run-time for specific rows of a table (where the data is retrieved from a database). I have joined two variables for the checkbox value via a '+' symbol and want to grab each one of these variables as a separate entity and store them as key value pairs using the dictionary function so that I can then iterate through the key value pairs to delete records from the database that correspond to the value of the checkboxes stored in the dictionary. Unfortunately, however, the spilt function doesn't seem to work correctly when I try to grab the variables contained in the value of the checkbox and spilt them based on looking for the '+' symbol - the . I have inserted my code below for reference and would appreciate any guidance on what I'm doing wrong here:

    <form id="frmDeleteMass" method="POST" action="Invoices2.asp">

    <input type="checkbox" id="chk_delete" name="chk_delete" value="<%=rs(1)%>+<%=rs(5)%>" style="margin-top:5px;" onmouseover="return escape('<img src=\'../../Icons/database_delete.png\' width=\'16\' height=\'16\' border=\'0\' align=\'absmiddle\'><strong> Delete the entry</strong><BR> Click to delete the entry in the errors table for the following order (<span style=\'color:Red\'><%=rs(1)%></span>)')" />

    </form>

    <%
    Dim strIDs

    strIDs = Replace(Request.Form, "&chk_delete=", ",")
    strIDs = Replace(strIDs, "chk_delete=", "")

    if strIDs <> "" then

    Dim split_vers

    split_vers = Split(strIDs,"+")

    Dim values_store
    Set values_store=Server.CreateObject("Scripting.Dictionary")

    values_store.Add Split(split_vers(0), ","), Split(split_vers(1), ",") // This is where the problem is - no data is being retrieved using this method and hence an error is generated

    allKeys = values_store.Keys
    allItems = values_store.Items

    For i = 0 To values_store.Count - 1

    strSQL = "DELETE from Openquery(EFGL01A,'Select * from EFGL01A.SIERRORS" & allKeys(i) & " where yeorn5 = " & allItems(i) & "')"

    conn.Execute (strSQL)

    Next

    end if

  2. #2
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After doing a response.write for the strIDs variable, it would seem that the following is output after the values extracted from the checkboxes:

    &btnDeleteAll=Delete+All+Selected+Entries+%3E%3E%3E

    Could this be part of the problem? Why would this be happening please?

  3. #3
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you see the form and its contents displayed on the screen, have you done a view page to see what the values are in the form before they are submitted ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •