Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:56:46+00:00 2026-05-23T14:56:46+00:00

I’m having problems setting the unchecked state of checkboxes upon form post. I have

  • 0

I’m having problems setting the unchecked state of checkboxes upon form post. I have over 1000 checkboxes and so far i am able to check each checkbox n save there checked state. My problem however is unchecking the checkboxes.

  • I’m not having problems saving the checked state of each checkbox after form is posted. My problem is unchecking values then having that unchecked state saved after form post.

I’m also using paging on the page as shown in the code below (Values of submit buttons are parameters of a stored procedure)-

    <center><input id="buttonStyle" type="submit" name="Page" value="#">
        <% for i = 97 to 122 %>
             <input id="buttonStyle" type="submit" name="Page" value="<%=CHR(i) %>">&nbsp;
        <% next %></center>
<input id="buttonStyle" type="submit" name="Page" value="View All">

I need to save my checked state as I view each letter. So far thanks to the help of shadowwizard I am able to save checked and unchecked states of checkboxes if I click view all button. However the problem now is that when i click another letter (e.g – a, b, c) any checked state is removed when clicking view all.

<% 
        Dim tempArray
        Dim checkArray
        Dim temphiddenArray
        Dim hiddenArray

        'CheckBox Selection Array
        if len(Request.Form("selectedRecord")) > 0 then tempArray = split(Request.Form("selectedRecord"), ",")
        if isarray(tempArray) then
            redim checkArray(ubound(tempArray))

            'Create CheckArray ARRAY
            for i = lbound(tempArray) to ubound(tempArray)
                checkArray(i) = trim(tempArray(i))
            next

            'Hidden Array check
            if len(request.Form("hiddenArray")) > 0 then temphiddenArray = split(request.Form("hiddenArray"), ",")
            if isarray(temphiddenArray) then

                redim hiddenArray(ubound(temphiddenArray))
                for i = lbound(hiddenArray) to ubound(hiddenArray)
                    hiddenArray(i) = trim(temphiddenArray(i))
                    Session("LastCheck_"&i) = hiddenArray(i)  
                next                    

                if ubound(hiddenArray) >= ubound(checkArray) then
                    for i = lbound(hiddenArray) to ubound(hiddenArray)
                        Session("CheckBox_"&(Session("LastCheck_"&i))) = ""
                    next
                end if        

            end if

            for i = lbound(checkArray) to ubound(checkArray)
                Session("CheckBox_"&checkArray(i)) = "Checked"        
                %>
                <input type="hidden" name="hiddenArray" value="<%=checkArray(i) %>">
                <%
            next

        else
            Session("CheckBox_"&request.Form("hiddenArray")) = ""
        end if
        %>

            <% while not objRS.EOF %>
            <input type="checkbox" name="selectedRecord" value="<%=objRS("Id") %>" <%=Session("CheckBox_"&objRS("Id")) %>>
            objRS.MoveNext
            wend
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:56:47+00:00Added an answer on May 23, 2026 at 2:56 pm

    You’re going through whole forest instead of climbing a short tree, or in other words making something simple terribly complicated.

    What you need is this function:

    <%
    Function WasCheckedByUser(id)
        Dim x
        WasCheckedByUser = "checked=""checked"""
        For x=1 To Request.Form("selectedRecord").Count
            If Trim(Request.Form("selectedRecord").Item(x))=Trim(id) Then
                Exit Function
            End If
        Next
        WasCheckedByUser = ""
    End Function
    %>
    

    Then use it like this:

    <input type="checkbox" name="selectedRecord" value="<%=objRS("Id") %>" <%=WasCheckedByUser(objRS("Id")) %>/>
    

    No need in arrays, no need in Session variables. Just simple iteration over the posted values (which are the values of the checked checkboxes) and if certain value is there, it means the corresponding checkbox should be checked, otherwise leave it unchecked.

    Edit: you lose the “state” because when you click specific letter, you send to the browser only part of the checkboxes – so the previous value is indeed “lost” for good.

    The most simple way to fix that is to send all checkboxes to the browser – always – and using simple style hide those that you currently don’t send at all.

    So, you’ll have to change the SQL used to populate objRS to always select all, and change the loop to this:

    <%
    Do Until objRS.EOF
        Response.Write("<input type=""checkbox"" name=""selectedRecord"" value=""" & objRS("Id") & """ " & WasCheckedByUser(objRS("Id")))
        If Len(Request.Form("Page"))=1 And Trim(Left(objRS("Id"), 1))<>Trim(Request.Form("Page")) Then
            Response.Write(" style=""display: none;""")
        End If
        Response.Write(" />")
        objRS.MoveNext
    Loop
    %>
    

    As far as I can see it should work and now preserve the state even for the hidden checkboxes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.