Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Maintain state of checkbox While Paging

Posted on 2004-10-26
6
Medium Priority
?
367 Views
Last Modified: 2008-01-09
I need to maintain a checkbox's "checked" status while paging back and forth with a querystring on the same page. I think this will require vb or javascript to work.

Here is my code:

<%
Dim i
      For i=1 To pagesize

If NOT RS.EOF Then
      r = n Mod 2
      if r <> 0 then
         rowColor = "#FFF0AF"
      else
         rowColor = "#F0FFCF"
      end if

Dim vAuthCode,vNPANXX,vAddDate,vActiveDate,vDeactiveDate
Dim vRouting,vCarrier,vAuthType

vAuthCode = RS("auth_code")

vA_NPA = left(RS("auth_code"),3)
vA_NXX = mid(RS("auth_code"),4,3)
vA_Num = right(RS("auth_code"),4)
%>
<tr bgcolor="<%=rowcolor%>">
<td align=center nowrap><font class=content><%=vA_NPA%>-<%=vA_NXX%>-<%=vA_Num%></font></td>
<td align=center nowrap><input type=checkbox name="ordernum" id="ordernum" value="<%=vAuthCode%>"></td>
</tr>
<%
      n=n+1
   RS.MoveNext
 End If
Next
%>
<tr><td colspan=99 align=right bgcolor="#BBBBBB">
<input type=hidden name="action" id="action" value="bulkOrder"><input style="width: 200px;" class=button type=submit name=submit1 id=submit1 value="RESERVE SELECTED NUMBERS" onClick="return confirmSubmit()"></td></tr></table></td></tr></table>
</td></tr></table>
<p>
<blockquote><font class=content><b>Jump to Page: </b>
<%
if not isEmpty(Request.QueryString("sort")) then
column=Request.QueryString("sort")
vSort="sort=" & column
ElseIf not isEmpty(Request.QueryString("sortd")) then
column=Request.QueryString("sortd")
vSort="sortd=" & column
Else
vSort=auth_code
End If

Dim x, lb, ub
      For x=1 To numpages
        lb = (x-1) * pagesize + 1
        ub = x * pagesize
        If ub > numrecs Then ub = numrecs
        If x <> mypage Then
          Response.Write("<a class=content href=number_inventory.asp?page=" & x & "&select2="& vFilter2 &"&recs=" & pagesize & "&"& vSort &">" & lb & "-" & ub & "</A>")
        Else
          Response.Write(lb & "-" & ub)
        End If
        If x <> numpages Then Response.Write(" | ")
Next

End If

      RS.Close
      Set RS = Nothing
      objConn.Close
      Set objConn = Nothing
%>
0
Comment
Question by:xeroflux
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 12414650
input type=checkbox name="ordernum" id="ordernum" value="<%=vAuthCode%>" <% if( Request.QueryString( "ordernum" ) <> "" ) then Response.Write( "checked" ) end if%> >
0
 
LVL 7

Expert Comment

by:kmorris1186
ID: 12414726
Building on justinbillig's comment.

Lets say you have this variable that you want to carry over to another page..

CurTime = now()

You 1st need to send it to the next page.  The only way this can be done is with a Form or Querystring depending on your needs. I have done it with both.

Response.redirect("nextpage.asp?CurTime=" & CurTime)

Then on the next page you can get the CurTime value using this:

CurTime = Request.QueryString("CurTime")
0
 

Author Comment

by:xeroflux
ID: 12414984
The pagination runs on the same page. The only time the form would be submitted is after you've checked your checkboxes from the various pages.

The paging querystring could be used to trigger a javascript that detects what has been checked on each page and holds them in a cookie or array.

Neither of your answers really solves the problem.
0
 
LVL 15

Accepted Solution

by:
gladxml earned 2000 total points
ID: 12418638
xeroflux,

I am not sure but this is just an idea. I think the only way to go over your problem is using cookies cause it can be set using client side scripting like javascript. You can use the checkbox as a way in setting the cookies. When you check one of the checkbox you will set the cookies using client side scripting

below is a link that might help...
http://www.the-cool-place.co.uk/javascript/tutorial/javascript3.html

Now when you pass the page on the pages you can read the cookies using serverside so that you can preserved the checkbox value

below is a link that might be helpful in reading cookies server side.
http://www.w3schools.com/asp/asp_cookies.asp

now you can something like this in your page

<input type=checkbox name="ordernum" id="ordernum" value="<%=vAuthCode%>" <%=setSelect(vAuthCode)%>>

Now your function would be something like this...

Function setSelect(a)
for each x in Request.Cookies
if trim(a) = trim(Request.Cookies(x))then
setSelect = "checked"
exit for
end if
next
end function

This will compare the the dynamic values with cookie collection everytime the page is loaded put checked if data is the same... that way will preserv the checkboxes...

This is just an idea out of my brain... I am not sure if this will work but you can give it a try....

HTH...

HAppy programming...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question