Page 1 of 1

Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Wed Feb 19, 2014 5:43 pm
by danpickard

I've got a dynamic list which loads multiple items into the check box group. I'd like it so that once one check box item has been ticked you can't tick anymore.

Here is a screenshot of what it currently does when I select multiple boxes:

Image

Ideally I'd like to limit the check box selection to just 1 box.

How would I go about doing this?


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Wed Feb 19, 2014 6:08 pm
by Maryna Brodina

Hello! You can do that with JS only. If you need just 1 box use radiobatton, not checkbox.


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Wed Feb 19, 2014 7:27 pm
by danpickard

oh ok, thanks :)


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Wed Feb 19, 2014 9:50 pm
by danpickard

Suppose that one team is selected from the list of radio group options and the name of that is stored in a local storage variable, is there a way to make sure that when re visiting that page the same selection is automatically made?

For instance, if Barcelona is selected as a radio button, then I go to a different page, that next time the service is loaded on the 'Teams' page Barcelona is the one that is selected


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Thu Feb 20, 2014 8:56 am
by Kateryna Grynko

Hi Dan,

You can save the selected checkbox value https://getsatisfaction.com/apperyio/... and call an appropriate service then.


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Thu Feb 20, 2014 4:26 pm
by danpickard

Can't seem to make the radio button value stay checked.
the JS I've got for it is:

code
var text = localStorage.getItem('teamSelected');
Appery("teamsRadioGroupItem").find(text).attr("checked", true);
/code

Can you see any immediate problems?


Is there a way to make a check box group limit the number of boxes ticked to 1?

Posted: Thu Feb 20, 2014 11:50 pm
by Illya Stepanov

Hi Dan,

This is the algorithm for your goals:

ol
liCreate radio list (call it 'radioList')./li
liCreate datasource. Attach it to your list by the mapping. Invoke this datasource on the page load event./li
liAdd event listiner "Value change" to "radioList" component. And fill it by following js code:
pre
var selectedItemValue = Appery("radioList").find("input:checked").val();
localStorage.setItem("selectedItemValue", selectedItemValue);
/pre
/li
liAdd event listiner "success" for your list datasource. And insert the next code:
pre
var selectedItemValue = localStorage.getItem("selectedItemValue");

var selectedItem = Appery("radioList").find("input[value='" + selectedItemValue + "']");
if(selectedItem.length == 0)
return;

selectedItem.click();
/pre
/li
/ol