Link to home
Start Free TrialLog in
Avatar of xeroflux
xeroflux

asked on

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
%>
Avatar of justinbillig
justinbillig

input type=checkbox name="ordernum" id="ordernum" value="<%=vAuthCode%>" <% if( Request.QueryString( "ordernum" ) <> "" ) then Response.Write( "checked" ) end if%> >
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")
Avatar of xeroflux

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of gladxml
gladxml

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial