Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receiving Multiple Checkbox Values

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
With a single Submit button, I am trying to send the values of multiple check boxes to update an SQL Server table. The "Name" of each checkbox is the ID to be updated while the "Value" depends on wheather or not it's checked. So the data string being submitted is something like:

1012=0&1042=1&1023=1&1111=1&1077=1&1052=1&1110=1&1074=1&1028=1&1073=1&1057=1&1128=1&1072=1 etc.

Question is, how can I take these form "pairs" and give them variable names for use in the Update statement? Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Try something like this. I take a radio box, and based on whether or not it is selected i execute a SQL command, then I just loop through the radio buttons to do it for all of them. Basically, you do it by naming the box a standard name plus a number that. like Approve1, Approve2, Approve3. The number gets incremented as you draw out the boxes. Then you pass the final value of the number back to the page as a hidden variable. Then you have something to loop through.


Here is the part that executes the SQL statement against the database.


if request.form("btnsubmit") = "Approve" then
'-- Checks to see if button to approve was clicked

for i=1 to Request("total")
'-- Loops the SQL statement for the total amount of records listed

if request.form("approve" & i) = "yes" then
UpdateSQL = "Insert into mytable (1,2,3,etc....)"
end if



The rest is the piece that draws out the radio boxes.


if not rsud.bof then
rsud.movefirst
end if
i=0
Do until RSUD.eof
i=i+1
response.write &quot;<tr>&quot;
response.write &quot;<td><input type=radio name=approve&quot; & i & &quot; value=yes></td><td><input type=radio name=approve&quot; & i & &quot; value=no><input type=hidden name=leaveid&quot; & i & &quot; value=&quot; & rsud(&quot;leaveid&quot;) & &quot;></td>&quot;
for E=0 to howmanyfields
response.write &quot;<td><font size=1>&quot; & RSUD(e) & &quot;</font></td>&quot;
end if
next
RSUD.movenext
loop
%>
</table>
<table align=center>
<tr><td><input type=submit name=btnsubmit value=&quot;Approve&quot;></td><td><input type=reset value=&quot;Reset&quot;></td>
<% response.write &quot;<td><input type=hidden name=total value=&quot; & i & &quot;></td></tr>&quot; %>
</table>

The money's gone, the brain is shot.....but the liquor we still got.
 
Thanks! I'll see if I can work some of the ideas in once I go through your code more closely. The name and value from the checkboxes is coming dynamically from the same table so I don't have a lot of flexibility in renaming them but the idea of a static name and dynamic number number appended to it might work. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
I've been looking over the examples here and see some very useful code but I am not sure how to appy it to my question. I think the problem is that I am already looping through a recordset and that I am trying to perform an Update rather than an Insert. I already have a number of multiple checkbox Insert pages, which work fine.

What I have is a series of checkboxes with the name=&quot;RSid&quot; and the value=&quot;1&quot; (a boolian 0 or 1), both of which are coming from a recordset. What I want to be able to do is to change multiple entries from one form where ID=RSid for example and this is where I am bogging down since it seems to me that it is the Select Statement that needs to loop to get the RSid and value for each entry. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top