Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

how to split value of checkbox

i have a group of checkbox ,each user can choose up to 3 item, and i want to put the selected value to database. i can pass the value already to the database but the value selected are in array.
like this
Image
i want each value for one row,any solution? i really need reply asap

this is my code
var arr = new Array([]);
arr = Appery("chckbox_4yo").find(":checked").each(function(){
arr.push($(this).val());
});
if (arr.length === 0) {
alert("Please select a category!");
return;
}
if (arr.length 3) {
alert("sorry you has reached the amout of choosing category!");

} else {
var items = ['selectedCategory', 'selectedCategory2', 'selectedCategory3'];
$.each(arr, function(i, value){
localStorage.setItem(items, value);
});

Code: Select all

category_datasource.execute(); 

}

// restore from localStorage
var items = ['selectedCategory', 'selectedCategory2', 'selectedCategory3'];
$.each(arr, function(i, key){
var value = localStorage.getItem(key);
Appery("chckbox_4yo")
.find("input[value='" + value + "']:first")
.prop('checked', 'checked')
.refresh();
});

//Note: Replace "mobilecheckbox_146" with your checkbox name.
var checkedCheckboxes = jQuery('[name="chckbox_4yo"] input:checked').closest('[name="chckbox_4yo"]');
for(var i = 0; checkedCheckboxes.length; i++)
{
//Replace "mobilelabel_149" with your goal text label name.
var currentItemText = jQuery(checkedCheckboxes).find('[name="inCat"]').text().trim();
//Here is using currunt checked item text. You can change it in accordance to your needs.
alert(currentItemText);
}

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

how to split value of checkbox

Hi Nisa -

You will need to parse your array data into a string values and update records in your collection with this values.

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

how to split value of checkbox

can you guide me step by step? i'm still confuse with this

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

how to split value of checkbox

Hello Nisa,

Currently we do not have ready solution to share, please look at a similar post https://getsatisfaction.com/apperyio/...
Also this tutorial will come in handy https://devcenter.appery.io/documenta...

Return to “Issues”