How can I easily maintain checkbox state?

  • rperry
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 4 months ago #388 by rperry
How can I easily maintain checkbox state upon refresh?

Really need a clear how-to example on this. My site can be viewed here: HERE !

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago - 12 years 4 months ago #390 by andrea_4g
Replied by andrea_4g on topic Re: How can I easily maintain checkbox state?
That isn't a standard version of Custom Properties, is it? (as far as I know there's no way to have the 'Select / Unselect All' checked by default).

Try without the js script you addedd (// All Region checkboxes checked by default
$("input[name='cp_region[]']").prop("checked", true); ...) and set the values you want in checked state as default.
Last edit: 12 years 4 months ago by andrea_4g.

Please Log in or Create an account to join the conversation.

  • rperry
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 4 months ago #398 by rperry
Yes, it is the standard version of Custom Properties, with a bit of custom JavaScript to get the functionality I'm looking for. I was able to create it select unselect all checkbox. what I'm looking for is the ability to maintain checkbox state upon page reload. This should be doable via cookies and JavaScript.

Concerning your recommendation below, I'm only allowed to select one checkbox as the default in the backend. I use JavaScript to select all checkboxes by default.

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago - 12 years 4 months ago #399 by andrea_4g
Replied by andrea_4g on topic Re: How can I easily maintain checkbox state?

I'm only allowed to select one checkbox as the default

Nope, you *were* only allowed to select one checkbox as the default. Starting from version 2.0.6 *more* fields can be set as default. :)

Achieving the same results working only on the client side (js + cookie) is not easy / reliable at all. You need to store the state of each control before form submission, then retrieve that from the cookie when the page reloads, compare with checked boxes on new page, figure out if user has done any selections, decide if you need to restore the default state, ... to sum it up: you are entering in a world of pain ;)
Last edit: 12 years 4 months ago by andrea_4g.

Please Log in or Create an account to join the conversation.

  • rperry
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 4 months ago #401 by rperry
Sounds like a great challenge to me! I'll let you know when it's done.

Please Log in or Create an account to join the conversation.

Time to create page: 0.132 seconds