- Posts: 12
- Thank you received: 0
How can I easily maintain checkbox state?
- rperry
- Topic Author
- Offline
- New Member
Less
More
12 years 10 months ago #388
by rperry
How can I easily maintain checkbox state? was created 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 !
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.
- andrea_4g
- Offline
- Administrator
Less
More
- Posts: 1122
- Thank you received: 163
12 years 10 months ago - 12 years 10 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.
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 10 months ago by andrea_4g.
Please Log in or Create an account to join the conversation.
- rperry
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
12 years 10 months ago #398
by rperry
Replied by rperry on topic Re: How can I easily maintain checkbox state?
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.
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.
- andrea_4g
- Offline
- Administrator
Less
More
- Posts: 1122
- Thank you received: 163
12 years 10 months ago - 12 years 10 months ago #399
by andrea_4g
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
Replied by andrea_4g on topic Re: How can I easily maintain checkbox state?
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.I'm only allowed to select one checkbox as the 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 10 months ago by andrea_4g.
Please Log in or Create an account to join the conversation.
- rperry
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
12 years 10 months ago #401
by rperry
Replied by rperry on topic Re: How can I easily maintain checkbox state?
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.141 seconds