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
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);
}