danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

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

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

danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Dan,

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

danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

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

Return to “Issues”