Page 1 of 1

Checkbox index

Posted: Fri Jan 23, 2015 11:30 pm
by Jakub

Is there a way to get an index of checkbox array?
I am filling a Checkbox from REST service and need to get an index of a clicked checkbox.
This is the code I used for Listview
var li = jQuery(this).closest("li");
var index = li.index('li:not([data-role="list-divider"])');

But is does not work when I change it for checkbox, I get index number that is + 2 than what is should be when clicked (fist item in array should be 0 but index is 2).
var li = jQuery(this).closest("input");
var index = li.index('input');

What am I doing wrong?


Checkbox index

Posted: Sat Jan 24, 2015 3:03 pm
by Alena Prykhodko

Hello Jacub,

This code allows to get the checkbox item value:
preApperyio("mobilecheckbox_5").find('input[type="checkbox"]').val();/pre
Also read more here http://devcenter.appery.io/documentat...


Checkbox index

Posted: Sun Jan 25, 2015 2:30 am
by Jakub

Thanks Alena,

But I need the index value of the checkbox (0,1,2,3,4), as it should correspond to the index of underlying array the checkbox list is built from.

Thank you.


Checkbox index

Posted: Tue Jan 27, 2015 7:41 pm
by Alena Prykhodko

Hello,

Try this pre$("[name=checkboxgroup]").each(function(index,element){
if (index !==0){
console.log("state= "+ element.checked+" i"+index)
}
})/pre