php - Check a multidimensional array input in javascript -


i have input type hidden in loop, it's multidimensional array , has 1 input name.
how can check if there value in it? value or element?

code: (the array generated in php in loop)

echo "<td class='$border'>     <div class='dropzonepers'></div>     <input type='hidden' value='' name='pers[$dag][$j]'/> </td>"; 

what have tried in js:

if($(".pers").length !> 0) {    alert("no!");    return false; } 

how can that?

grab input elements have name starts "pers" , see if not empty

function persisempty() {     var empty = true;     $('input[type="hidden"][name^="pers"]').each(function () {         if ($(this).val().length > 0 && $(this).val() != '') {             empty = false;         }     });     return empty; } 

//...so like

if (persisempty()) {     alert("no!");     return false; } 

see: https://css-tricks.com/attribute-selectors/


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -