Submitting multiple record IDs via a form.

C

CJM

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
 
R

Ray at

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
 
T

Tom B

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 said:
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 said:
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
 
C

CJM

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

Thanks

Tom B said:
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 said:
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 said:
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 is
an the
 
C

CJM

That's exactly what I was looking for.

Glad I asked now..

tx

Chris

Ray at said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top