Maintain state of checkbox While Paging

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
%>
xerofluxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

justinbilligCommented:
input type=checkbox name="ordernum" id="ordernum" value="<%=vAuthCode%>" <% if( Request.QueryString( "ordernum" ) <> "" ) then Response.Write( "checked" ) end if%> >
0
kmorris1186Commented:
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
xerofluxAuthor Commented:
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
gladxmlCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.