php - How can I get the SearcIDs of different searchNames using javascript -


can me sort problem out? i'd id of searchname each time user checks checkbox. want pass value of php line $search_row->searchid id in input if possible. sorry if question wrongly asked. please help!!!

<li class="treeview">                <a href="#">         <i class="active fa fa-search"></i>          <span>searches</span>          <i class="fa fa-angle-left pull-right"></i>         </a>     <ul class="treeview-menu">         <li style="padding-left: 10px;">             <input type="checkbox" id="selectall" onclick='selectall(this.checked)'>              <span style="color: #fff; ">select all</span>         </li>         <?php foreach ($query $search_row){ ?>             <li style="padding-left: 10px;">                 <input type="checkbox" id="searchid" onclick="getsearchid()" name="searchname">                  <span style="color: #fff; ">                     <?php echo $search_row->searchname;?>                      <?php echo '<br>';?>                     <?php $search_row->searchid ;?>                     <span>             </li>          <?php }?>              </ul> </li> 
function getsearchid(){     var checkedvalues = "";     var count = 0;      checkedvalues = $('#searchid:checked').map(function () {         count = count + 1;         return this.value;     }).get().join(",");      localstorage.setitem("#searchid", checkedvalues);     alert(checkedvalues); } 

id must unique, should use class instead

php

<?php foreach ($query $search_row){ ?>   <li style="padding-left: 10px;">     <input type="checkbox" class="searchid" onclick="getsearchid()" name="searchname" />       ...   </li>  <?php }?>  

js

... checkedvalues = $('.searchid:checked').map(function () {   count = count + 1;   return this.value; }).get().join(","); 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -