473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to persist checkbox selections across recordset pages

Hi All,
I have a large recordset to be displayed on a ASP 3.0 page. I am using
recordset paging for this. For the next and previous link i am passing href
as
<a href=<Page URl>?page=<%= iPageCurrent - 1 %for Previous.
Now when i display the contents i also add a checkbox (for deletion) to each
of the records.
Now user should be able to select one or more checkboxes across pages and
then should be allow to delete all selections together.
Can anyone please point me right directions or give some hints on how to
acheive this.
Thanks and Regards,
Parag
Jul 13 '07 #1
11 4271
Not that I know of - unless you change my function mytester to set a
cookie in javascript, that would work as well I think. Then you would
not be passing data around - simply changing a cookie value.
Ther are plent of article on Javascript and Cookies, just punch
"javascript cookies" inbto google.

Regards
Dave

Jul 20 '07 #2
Thanks once again Dave.
Based on the discussions till now I can see three ways to acheive this
1. Querystrings as explianed by your examples. But this means user can the
see values and Querystring has length limitation (though quite long). However
this will work in all browsers
2. Submit the page on click of Next and Prev buttons. store the selections
in hidden field. This i can pass the data without being visible. Not sure how
much performance impact this may have.
3. Cookies - Again here i think the limit is 4K so not sure how many
selections can be stored and also browser needs to support this.
Can you please let me know which would be best option considering following
criterias
1. Performance
2. Data Security
Thanks and Regards,
Parag

"daddywhite" wrote:
Not that I know of - unless you change my function mytester to set a
cookie in javascript, that would work as well I think. Then you would
not be passing data around - simply changing a cookie value.
Ther are plent of article on Javascript and Cookies, just punch
"javascript cookies" inbto google.

Regards
Dave

Jul 20 '07 #3
On Jul 20, 4:44 pm, Parag Gaikwad
<ParagGaik...@discussions.microsoft.comwrote:
Thanks once again Dave.
Based on the discussions till now I can see three ways to acheive this
1. Querystrings as explianed by your examples. But this means user can the
see values and Querystring has length limitation (though quite long). However
this will work in all browsers
2. Submit the page on click of Next and Prev buttons. store the selections
in hidden field. This i can pass the data without being visible. Not sure how
much performance impact this may have.
3. Cookies - Again here i think the limit is 4K so not sure how many
selections can be stored and also browser needs to support this.
Can you please let me know which would be best option considering following
criterias
1. Performance
2. Data Security
Thanks and Regards,
Parag
Submission obviously means that there is no limit to what is stored

Any of these methods would work - yes there are problems with 1 and 3
but it all depends on how many records you expect a user to want to
delete in any one action - if hundreds then dont use querystrings or
cookies. If on a few (less than 40/50) then use any of these methods.

I wouldnt worry about the browser problem with cookies - you can
always check whether they have cookies enabled and if not warn them
and tell them to switch them on - but i dont see how they would get
most websites to work if they have cookies disabled.

Regards
Dave.

Jul 21 '07 #4
Thanks for the response Dave.
I think I would implement one of the following options. However, I am not
100% sure which one to use. Would really appreciate your advice
1. Hiden Field & Submit the Form on click of next and previous button
Pros
- Data is not visible to user
- No storage Limitation
Cons
- Form needs to be submitted resulting some overhead not sure what (main
cause of not being 100% sure)

2. Use cookies to store selection
Pros
- Data is not easily visisble
- Available at client side not sure if boost performance as read write
operation to the cookie file
Cons
- Size limitation. I think t is 4096 bytes or 255 characters.
- The clicking on next button will do saving to cookie and trip to server
though..

Some users might delete more than 50 records...so really bit confused. If I
have to go cookie way then have to restrict users from checking more that say
50 records.
Please let me know your thoughts
Thanks and Regards,
Parag
"daddywhite" wrote:
On Jul 20, 4:44 pm, Parag Gaikwad
<ParagGaik...@discussions.microsoft.comwrote:
Thanks once again Dave.
Based on the discussions till now I can see three ways to acheive this
1. Querystrings as explianed by your examples. But this means user can the
see values and Querystring has length limitation (though quite long). However
this will work in all browsers
2. Submit the page on click of Next and Prev buttons. store the selections
in hidden field. This i can pass the data without being visible. Not sure how
much performance impact this may have.
3. Cookies - Again here i think the limit is 4K so not sure how many
selections can be stored and also browser needs to support this.
Can you please let me know which would be best option considering following
criterias
1. Performance
2. Data Security
Thanks and Regards,
Parag

Submission obviously means that there is no limit to what is stored

Any of these methods would work - yes there are problems with 1 and 3
but it all depends on how many records you expect a user to want to
delete in any one action - if hundreds then dont use querystrings or
cookies. If on a few (less than 40/50) then use any of these methods.

I wouldnt worry about the browser problem with cookies - you can
always check whether they have cookies enabled and if not warn them
and tell them to switch them on - but i dont see how they would get
most websites to work if they have cookies disabled.

Regards
Dave.

Jul 23 '07 #5
To be honest its down to personal prefernce.

Use whichever you like.

If you want to restrict the user to 50 clicks (or however many) then I
have the code to do that if you wish. Alternatively I suppose you
could javascript to count the characters and if over 200 then disallow
any more selections? I dunno.

If it is truly 255 character limit it depends on the size of the ids
of record you want to delete. For example if an ID is "25678655" then
that uses up more characters than "23" obviosuly!
Jul 23 '07 #6
Parag,

Jim is right this will work also , it depends if you mind that the
records are deleted straight away or not.

I assumed you would the user to leisurely scroll through the pages
selecting (and maybe even deselecting) which records to delete before
finally clicking "Delete All checked records" link or something
similar.

It depends on the nature of the application/website.

Regards
Dave

Jul 24 '07 #7
Dave,
Your assumption is correct. I do need the functionality as you mentioned
i.e. Delete all selected records link.
As mentioned in my reply to Jim
The only question in my mind is :- On clicking of the next and prev the form
is submitted. How much impact this has on performance instead of just calling
the same page url (in href) with different PAGE QUERYSTRING value.
Your views on this would be really helpful.
Thanks and Regards,
Parag
"daddywhite" wrote:
Parag,

Jim is right this will work also , it depends if you mind that the
records are deleted straight away or not.

I assumed you would the user to leisurely scroll through the pages
selecting (and maybe even deselecting) which records to delete before
finally clicking "Delete All checked records" link or something
similar.

It depends on the nature of the application/website.

Regards
Dave

Jul 24 '07 #8
I dont personally think there will be a noticable impact on
performance. After all its only one extra fiels your submitting. I
think your worrying about nothing there.

Get on with it and let us know how you get on.

Regards
Dave

Jul 24 '07 #9
"Parag Gaikwad" wrote:
The only question in my mind is :- On clicking of the next and prev the form
is submitted. How much impact this has on performance instead of just calling
the same page url (in href) with different PAGE QUERYSTRING value.
Parag,

I prepared a tutorial for you. This took a long time. I didn't
have the time also to go back and check everything Dave told
you, so I don't if is redundant, or in conflict or what. Please
read this carefully, and I apologise if I'm telling stuff you
already know. I want to be helpful. It is my way of paying
back this newsgroup for helping me with hard problems (and
with easy ones, too.)

Before I start let me go ahead and say this: there are no
performance differences to worry about. Actually, you may
have a lot of work to do. Performance is the least of your
problems.

======================================
Links and the Two Types of Forms
======================================

Clicking on a Submit button when the form is like this...

<form method="get" action="myPage.asp">
<input type="checkbox" name="fileName1" value="delete">
<input type="checkbox" name="fileName2" value="delete">
</form>

-IS- the -EXACT- same thing as clicking on a link where...

<a href="myPage.asp?fileName2=delete">
Next Page
</a>

....assuming that only checkbox #2 is checked.

So, these two are the same. But, this is also the same as
when method="post" except for two things:

(1) The "post" method hides the data so the user will not
see it in the URL. With the href or with method="get",
the data appears on the URL when the user gets to the
next page.

(2) Usually putting the data into the URL is not important,
but it can be if the length limit of URL (the QUERYSTRING
limit) also limits how many rows you can delete. Which
it does. NOTE: method="post" does not put the data
into the URL QUERYSTRING. It puts it into the IP packets
somewhere that more data is allowed than on the URL.

Another difference is you use different ASP functions when
you read the data on the "next page." Here are the functions:

— for forms with method="get" and for links (href="...")

strControlValue = Request.QueryString("strControlName")

— and for forms with method="post"

strControlValue = Request.Form("strControlName")

....where "strControlName" is the value you had in name=""
on the checkbox (or any other input of the form). And the
value="" parameter will go into strControlValue on the "next
page."

======================================
How to Structure an ASP file
======================================

I say "next page" because it is the same page, of course. Go
back and read my examples again. Try to understand every
line. The first thing you do on this page is to determine what
happenned that brought you to this page. Did someone enter
the page name in the address bar of their browser? Did the
user click on "Previous"? On "Next"? You need to figure this
out first thing at the beginning of your asp page.

Now, from a programming point of view, there are many ways
to go through the data once you are back again after clicking
on the "Next" or "Previous" button. Let's talk about that for a
minute.

This is HTML: When you have many checkboxes on a page,
and only some of them are checked, it is these checked ones
that appear in the data. The unchecked boxes are ignored.
The checked boxes appear on the next page as either values
in the Query string or as values in the Form collection.

In the Query string, of course, they look like this:
myPage.asp?name1=value1&name2=value2&name2=value2

In the Form(i) collection, you have to "look" at each Form(i).

Because you don't know the names of the checkboxes that
were checked beforehand, part of what you have to do is to
determine which ones if any were checked. So, you go
through the Query string or through the Form(i)'s until you
get to the end.
======================================
How to Delete a Bunch of Records
======================================

In my previous example, I described how you can
read the Form data from Request.Form(i) and delete the
records. That technique was BACKWARDS from what a lot
of people know. Here, I will show you the "forwards"
way to do this. Both work well. It's personal.
Most programmers would probably prefer the following
technique for your particular problem.

Suppose you named every checkbox with the same name,
and that is name="delete". And each value was something
like value="record1" and value="record2" and like that.
Then what you find when you get to the next page is this...

delete=record1,record2,record3 ...and so forth

(assuming these are the checkboxes you checked)

You can use the VBScript function Split() to make an array
of records_to_delete like this:

Dim strTemp, strRecords
strTemp = Request.Form("delete")
strRecords = Split(strTemp,",")

or if you use href="myPage.asp" (or method="get") then

Dim strTemp, strRecords
strTemp = Request.QueryString("delete")
strRecords = Split(strTemp,",")

....no real differences between them except the limitations in
length you know about already. Split() makes strRecords into
an array containing all the things in strTemp that were
separated by commas.

When you want to delete a file you can do this...

Dim myConnection, iRec, nDeleted
myConnection = Server.CreateObject("ADODB.Connection")
For iRec = 1 to UBound(records)
myConnection.Execute "DELETE * FROM myTable " & _
"WHERE priKey='" & records(iRec) & "';" _
, nDeleted
Next ' delete each record one at a a time

It depends on the database you use, but I think you might be
able to do the following if you want to delete them all at once:

Dim strSQL, iRec, nDeleted
If UBound(strRecords)>0 Then
strSQL = "DELETE * FROM myTable WHERE priKey IN ("
strSQL = strSQL & " '" & strRecords(iRec) & "'"
For iRec = 2 to UBound(strRecords)
strSQL = ", '" & strRecords(iRec) & "'"
Next
strSQL = strSQL & " );"
myConnection.Execute strSQL, nDeleted
Response.Write "<br>" & CStr(nRecords) & _
" were deleted.<br>" & vbCrLf
End If

I tested this for you and it WORKS with an MSAccess database
file (.mdb) assuming that "priKey" is the name of your primary
key and it is a string. Leave out the single quotes if it
is not a string.

If the priKey value were not strings, you could even
do this:

Dim strTemp, strRecords, strSQL, iRec, nDeleted
strTemp = Request.Form("delete")
strRecords = Split(strTemp,",")
If UBound(strRecords)>0 Then
strSQL = "DELETE * FROM myTable " & _
"WHERE priKey IN (" & strTemp & " );"
myConnection.Execute strSQL, nDeleted
Response.Write "<br>" & CStr(nRecords) & _
" were deleted.<br>" & vbCrLf
End If

In fact, if strKey values WERE strings, this should work:

Dim strTemp, strRecords, strSQL, iRec, nDeleted
strTemp = Request.Form("delete")
strRecords = Split(strTemp,",")
strTemp = "'" & Replace(strTemp, ",", "','") & "'"
If UBound(strRecords)>0 Then
strSQL = "DELETE * FROM myTable " & _
"WHERE priKey IN (" & strTemp & " );"
myConnection.Execute strSQL, nDeleted
Response.Write "<br>" & CStr(nRecords) & _
" were deleted.<br>" & vbCrLf
End If
======================================
A Few More Ideas For the Webpage
======================================

You could have on each page THREE buttons. All of
them have name="Choice" loike I mention in my previous
message. One button is to DELETE the records which
are checked, and the other two for the Next and Previous
functions.

Putting it all together, this the new part of your
new asp file:
'
Dim strTemp, strRecords, strSQL, iRec, nDeleted
Dim myConnection
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open "...Connection String goes here..."
'
'
' First, take care of the records.
'
'
Select Case UCase(Request.Form("Choice"))
Case "DELETE"
'
strTemp = Request.Form("delete")
strRecords = Split(strTemp,",")
strTemp = "'" & Replace(strTemp, ",", "','") & "'"
If UBound(strRecords)>0 Then
strSQL = "DELETE * FROM myTable " & _
"WHERE priKey IN (" & strTemp & " );"
myConnection.Execute strSQL, nDeleted
Response.Write "<br>" & CStr(nRecords) & _
" were deleted.<br>" & vbCrLf
Else
Response.Write "<br>NO records were deleted.<br>" & vbCrLf
End If
End Select
'
'
'
' Next, render the correct page of records.
'
'
Select Case UCase(Request.Form("Choice"))
Case "PREVIOUS"
'
' render the "PREVIOUS" page of records
'
Case "NEXT"
'
' render the "NEXT" page of records
'
Case "DELETE"
'
' render the "SAME" page of records again
'
Case Else ' you got here from ANOTHER page!
'
' render the "FIRST" page of records
'
End Select
'
'
myConnection.Close
Set myConnection = Nothing
Good Luck Parag,

Jim Rodgers


======= An Aside on References =======

By the way, good VBScript and ASP Classic references are
the following:

http://msdn2.microsoft.com/en-us/library/d1wf56tt.aspx
http://www.w3schools.com/vbscript/default.asp
http://msdn2.microsoft.com/en-us/library/ms524664.aspx
http://www.w3schools.com/asp/default.asp

The MSDN references are deteriorating rapidly. MS seems to
be circling the drain under new management. It is fantastically
ironic that the w3schools sites are even on this short list!
Others in this newsgroup will give you more great references.

======================================

Jul 24 '07 #10
Thanks a lot Dave.
I have not got it working both ways the Submit and cookie way.
Once again many thanks for helping me out.
Best Regards,
Parag

Jul 26 '07 #11
Thanks a lot Jim.
Your inputs were very useful.
I have got it working both ways i.e. submit and cookie.
Once again thanks for the help.
Best Regards,
Parag

Jul 26 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RelaxoRy | last post by:
Reposted (not sure if got sent) I have results being displayed each with its own checkbox name "selected" and value "id". When someone checks a checkbox, and then continues to page through...
9
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
2
by: Menelty | last post by:
I have 2 datagrids on my page and each one has a template column which has a checkbox relating to each specific row. I usually have one on the page and use javascript to make sure there has been x...
3
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
5
by: Corrine | last post by:
Given a backend on a network server and a frontend on a local computer, when is data pulled across the network? For example, does Rst.Recordcount pull data across the network? How about...
0
by: Scott P. | last post by:
I'm creating an app using ASP .NET (my second app so bear with me here) that basically builds a PDF file based on a bunch of user selections. I have a page which displays a series of checkboxs...
2
by: Deano | last post by:
I have a subform that is populated by a table that holds lots of yes/no values. The user sees points at the side and then periods across the top. So they decide they want point 20 for period 5...
3
by: delram | last post by:
I'm trying to get user selections (using checkboxes) on one JSP page(A.jsp) and pass them on to another page. So I have one page with a list of dynamically populated items like this 1 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.