简体   繁体   中英

JavaScript iterating through dynamic checkboxes on an aspx page

I have an aspx page that has dynamically created checkboxes. I'm trying to find a way to keep the state of this page (checkboxes that are checked to remain checked) when I hit the navigation button to go to the previous page. The problem is when I go from the previous page back to the page with the checkboxes I lose all of the values. I understand why I lose them but I can't figure out how to retain them. I was thinking about saving the ids of the boxes that are checked in a table but there just have to be a better way. Any help would be appreciated.

If you want to keep the data for a long time, then storing in a table is absolutely the right approach.

If you only need to store them temporarily, then storing the data in a session variable would be a good option.

You could also store the values directly in a cookie, which would give you the option to use either server side code or javascript to set the checkboxes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM