Copy link to clipboard
Copied
Hello, all.
I'm working on script where some panels are managed dinamically by the user or based on selection. I mean I'm using for loops to add children to the panel.
I want to know how can I check if, for example:
- At least one of the radiobuttons are selected
- At least one of the checkboxes are checked
- All edittext fields are filled with some text
Of course I don't have all those cases at once.
Hope I was clear on what I need.
Thanks in advance.
hi, you can put all objects in an array and check them as you want, for example:
function check_list(list,flag){
var rez = []
for(var i = 0; i < list.length; i++){
switch(flag){
case 'radiobutton':
case 'checkbox':
if(list[i].value){rez.push(true)}
break;
case 'edittext':
if(list[i].text != ''){rez.push(true)}
break;
}
}
switch(flag){
case 'radiobutton':
case 'checkbox':
if(rez.length != 0){return true}
break;
case 'edittext':
if(rez.length == list.
...
Copy link to clipboard
Copied
hi, you can put all objects in an array and check them as you want, for example:
function check_list(list,flag){
var rez = []
for(var i = 0; i < list.length; i++){
switch(flag){
case 'radiobutton':
case 'checkbox':
if(list[i].value){rez.push(true)}
break;
case 'edittext':
if(list[i].text != ''){rez.push(true)}
break;
}
}
switch(flag){
case 'radiobutton':
case 'checkbox':
if(rez.length != 0){return true}
break;
case 'edittext':
if(rez.length == list.length){return true}
break;
}
return false
}
mylist = []
mylist.push(children)
...
check_list(mylist,'element type')
Copy link to clipboard
Copied
Thank you so much, @SychevKA. It worked pretty well!
Copy link to clipboard
Copied
the message was duplicated and cannot be deleted, so I edited it