p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   how to get value from check box..... (http://p2p.wrox.com/showthread.php?t=12041)

cici April 20th, 2004 03:52 AM

how to get value from check box.....
I am writing a page where i wanted to update one or more records. I'm using check box to determine which record to be update.

but i dont know how to get the check box value and validate all the record under the particular selected field .

e.g. i need to edit record A and B, so i also need to validate all other records under record A and B is not empty.

How can i do this??:(

hope u all can understand.

advanced thanks.

happygv April 22nd, 2004 05:22 AM

Name all the checkboxes with same name with each having the value as the ID/Key field value in your table. When you submit that page, all the values of all check boxes (whichever is checked) are passed under the same name with values separated by COMMA. So you can loop through those values or use them as it is in you update statement depending on the nature of the Update statement.

Assume the following records.
KeyVal Name
1 Vijay
2 Cici
3 Planoie
4 Pgtips

If you have Checkboxes named as "chkUpdate" and Value of each checkbox for each record as 1, 2, 3, 4

Then If you have checked only the checkboxes of Vijay and Cici, then on submission to the other page, when retrieved as

Response.write Request.Form("chkUpdate")

will hold value as "1,2"

Then you can split them into an array using SPLIT function.

ArrUpdate = Split(Request(Form("chkUpdate"))

You can use this in Update statement looping through the array values

Start LOOP Based on i
 "Update MyTable Set Name=" & Request.Form("Name") & "Where KeyVal=" & Arr(i)

Note : I have just given you the Pseudocode above there. Syntactically you should make changes as needed.

Hope that helps.


-Vijay G

cici May 15th, 2004 08:35 AM

thanks! I will try it.

All times are GMT -4. The time now is 09:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.