Submitting multiple record IDs via a form.

Discussion in 'ASP General' started by CJM, Oct 23, 2003.

  1. CJM

    CJM Guest

    I have a problem more to do with style than ability; I can solve this
    problem in a number of ways, but I'm keen to find the best way of doing
    this...

    We have a facility on our intranet where users can log problems, comments &
    suggestions about the site to a DB.
    I'm building a page that lists the outstanding entries, and allows use to
    mark any number of entries as being 'done'

    That is, we have a number of rows, with the last field in each row being a
    checkbox to indicate the entry has been dealt with. At the end, there is an
    Update button which submits the form.

    The question is.. how to handle this...?

    The best solution I have thought of so far is to use the record ID as the ID
    for each checkbox. Then to Split() the resulting Request.Form into an array,
    loop through the array picking out the record IDs.

    It's not a bad solution, but I figured this must be a fairly common
    procedure and that somebody might have a slicker way of doing it...

    Any ideas?

    Chris
    CJM, Oct 23, 2003
    #1
    1. Advertising

  2. CJM

    Ray at Guest

    Name all the checkboxes the same, and use the ID number for the values, as
    so:


    <input name="chkID" value="1">
    <input name="chkID" value="5">
    <input name="chkID" value="13">
    <input name="chkID" value="19">


    Then on the page that processes, update them all with one SQL statement.

    sToUpdate = Request.Form("chkID")
    ''will return a string like 1, 5, 13, 19


    If Len(sToUpdate) > 0 Then
    sSQL = "UPDATE TheTable SET TheColumn=TheValue WHERE [ID] IN (" &
    sToUpdate & ")"
    ''create connection here
    YourADOConnection.Execute sSQL
    End If

    Ray at work

    "CJM" <> wrote in message
    news:...
    > I have a problem more to do with style than ability; I can solve this
    > problem in a number of ways, but I'm keen to find the best way of doing
    > this...
    >
    > We have a facility on our intranet where users can log problems, comments

    &
    > suggestions about the site to a DB.
    > I'm building a page that lists the outstanding entries, and allows use to
    > mark any number of entries as being 'done'
    >
    > That is, we have a number of rows, with the last field in each row being a
    > checkbox to indicate the entry has been dealt with. At the end, there is

    an
    > Update button which submits the form.
    >
    > The question is.. how to handle this...?
    >
    > The best solution I have thought of so far is to use the record ID as the

    ID
    > for each checkbox. Then to Split() the resulting Request.Form into an

    array,
    > loop through the array picking out the record IDs.
    >
    > It's not a bad solution, but I figured this must be a fairly common
    > procedure and that somebody might have a slicker way of doing it...
    >
    > Any ideas?
    >
    > Chris
    >
    >
    >
    >
    Ray at, Oct 23, 2003
    #2
    1. Advertising

  3. CJM

    Tom B Guest

    Don't forget to update the values that were unchecked. That is, if a
    checkbox had been checked, and then it was unchecked, it would not be
    reflected in Ray's solution.



    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > Name all the checkboxes the same, and use the ID number for the values, as
    > so:
    >
    >
    > <input name="chkID" value="1">
    > <input name="chkID" value="5">
    > <input name="chkID" value="13">
    > <input name="chkID" value="19">
    >
    >
    > Then on the page that processes, update them all with one SQL statement.
    >
    > sToUpdate = Request.Form("chkID")
    > ''will return a string like 1, 5, 13, 19
    >
    >
    > If Len(sToUpdate) > 0 Then
    > sSQL = "UPDATE TheTable SET TheColumn=TheValue WHERE [ID] IN (" &
    > sToUpdate & ")"
    > ''create connection here
    > YourADOConnection.Execute sSQL
    > End If
    >
    > Ray at work
    >
    > "CJM" <> wrote in message
    > news:...
    > > I have a problem more to do with style than ability; I can solve this
    > > problem in a number of ways, but I'm keen to find the best way of doing
    > > this...
    > >
    > > We have a facility on our intranet where users can log problems,

    comments
    > &
    > > suggestions about the site to a DB.
    > > I'm building a page that lists the outstanding entries, and allows use

    to
    > > mark any number of entries as being 'done'
    > >
    > > That is, we have a number of rows, with the last field in each row being

    a
    > > checkbox to indicate the entry has been dealt with. At the end, there is

    > an
    > > Update button which submits the form.
    > >
    > > The question is.. how to handle this...?
    > >
    > > The best solution I have thought of so far is to use the record ID as

    the
    > ID
    > > for each checkbox. Then to Split() the resulting Request.Form into an

    > array,
    > > loop through the array picking out the record IDs.
    > >
    > > It's not a bad solution, but I figured this must be a fairly common
    > > procedure and that somebody might have a slicker way of doing it...
    > >
    > > Any ideas?
    > >
    > > Chris
    > >
    > >
    > >
    > >

    >
    >
    Tom B, Oct 23, 2003
    #3
  4. CJM

    CJM Guest

    Fair point, but in this instance once an entry has been marked as 'done' is
    disappears... there is no unchecking capability.

    Thanks

    "Tom B" <> wrote in message
    news:...
    > Don't forget to update the values that were unchecked. That is, if a
    > checkbox had been checked, and then it was unchecked, it would not be
    > reflected in Ray's solution.
    >
    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > Name all the checkboxes the same, and use the ID number for the values,

    as
    > > so:
    > >
    > >
    > > <input name="chkID" value="1">
    > > <input name="chkID" value="5">
    > > <input name="chkID" value="13">
    > > <input name="chkID" value="19">
    > >
    > >
    > > Then on the page that processes, update them all with one SQL statement.
    > >
    > > sToUpdate = Request.Form("chkID")
    > > ''will return a string like 1, 5, 13, 19
    > >
    > >
    > > If Len(sToUpdate) > 0 Then
    > > sSQL = "UPDATE TheTable SET TheColumn=TheValue WHERE [ID] IN (" &
    > > sToUpdate & ")"
    > > ''create connection here
    > > YourADOConnection.Execute sSQL
    > > End If
    > >
    > > Ray at work
    > >
    > > "CJM" <> wrote in message
    > > news:...
    > > > I have a problem more to do with style than ability; I can solve this
    > > > problem in a number of ways, but I'm keen to find the best way of

    doing
    > > > this...
    > > >
    > > > We have a facility on our intranet where users can log problems,

    > comments
    > > &
    > > > suggestions about the site to a DB.
    > > > I'm building a page that lists the outstanding entries, and allows use

    > to
    > > > mark any number of entries as being 'done'
    > > >
    > > > That is, we have a number of rows, with the last field in each row

    being
    > a
    > > > checkbox to indicate the entry has been dealt with. At the end, there

    is
    > > an
    > > > Update button which submits the form.
    > > >
    > > > The question is.. how to handle this...?
    > > >
    > > > The best solution I have thought of so far is to use the record ID as

    > the
    > > ID
    > > > for each checkbox. Then to Split() the resulting Request.Form into an

    > > array,
    > > > loop through the array picking out the record IDs.
    > > >
    > > > It's not a bad solution, but I figured this must be a fairly common
    > > > procedure and that somebody might have a slicker way of doing it...
    > > >
    > > > Any ideas?
    > > >
    > > > Chris
    > > >
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    CJM, Oct 23, 2003
    #4
  5. CJM

    CJM Guest

    That's exactly what I was looking for.

    Glad I asked now..

    tx

    Chris

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > Name all the checkboxes the same, and use the ID number for the values, as
    > so:
    >
    >
    > <input name="chkID" value="1">
    > <input name="chkID" value="5">
    > <input name="chkID" value="13">
    > <input name="chkID" value="19">
    >
    >
    > Then on the page that processes, update them all with one SQL statement.
    >
    > sToUpdate = Request.Form("chkID")
    > ''will return a string like 1, 5, 13, 19
    >
    >
    > If Len(sToUpdate) > 0 Then
    > sSQL = "UPDATE TheTable SET TheColumn=TheValue WHERE [ID] IN (" &
    > sToUpdate & ")"
    > ''create connection here
    > YourADOConnection.Execute sSQL
    > End If
    >
    > Ray at work
    >
    > "CJM" <> wrote in message
    > news:...
    > > I have a problem more to do with style than ability; I can solve this
    > > problem in a number of ways, but I'm keen to find the best way of doing
    > > this...
    > >
    > > We have a facility on our intranet where users can log problems,

    comments
    > &
    > > suggestions about the site to a DB.
    > > I'm building a page that lists the outstanding entries, and allows use

    to
    > > mark any number of entries as being 'done'
    > >
    > > That is, we have a number of rows, with the last field in each row being

    a
    > > checkbox to indicate the entry has been dealt with. At the end, there is

    > an
    > > Update button which submits the form.
    > >
    > > The question is.. how to handle this...?
    > >
    > > The best solution I have thought of so far is to use the record ID as

    the
    > ID
    > > for each checkbox. Then to Split() the resulting Request.Form into an

    > array,
    > > loop through the array picking out the record IDs.
    > >
    > > It's not a bad solution, but I figured this must be a fairly common
    > > procedure and that somebody might have a slicker way of doing it...
    > >
    > > Any ideas?
    > >
    > > Chris
    > >
    > >
    > >
    > >

    >
    >
    CJM, Oct 23, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    695
    Beat Bolli
    Jun 21, 2005
  2. Josh Valino

    Getting IDs back when submitting

    Josh Valino, Feb 8, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    374
    Josh Valino
    Feb 11, 2008
  3. J.D. Buehls
    Replies:
    0
    Views:
    112
    J.D. Buehls
    Jun 18, 2004
  4. Richard Dixson

    Problem submitting form via JS

    Richard Dixson, Dec 13, 2004, in forum: Javascript
    Replies:
    1
    Views:
    127
    Martin Honnen
    Dec 13, 2004
  5. Steve Swift

    Submitting form via xmlhttp request

    Steve Swift, Jan 31, 2008, in forum: Javascript
    Replies:
    2
    Views:
    134
    David Dorward
    Jan 31, 2008
Loading...

Share This Page