dongyan2469 2014-01-19 06:31
浏览 50
已采纳

选中下拉列表时如何选中复选框

Please see the image what i am trying to do i have HTML table inside the each td i have drop down and check box,when i select value in drop down i want to make the check box checked for the particular td can anyone guide me how to do it.

enter image description here

code:

 <td style="width:141px" > <select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" >         
           <option value="-1">Choose..</option>';


            $query = "SELECT route FROM routestable WHERE `clientid` = '$client_id' "; 

            $result = mysql_query($query);

            while ($rows1 = mysql_fetch_assoc($result))  
            {  


                    if(strlen($rows1['route'])>0 && $rows1['route']==$rows['route']){
    print' <option value="'.$rows1['route'].'" selected>'.$rows1['route'].' </option>';}

                else{

                echo '<option value="' . $rows1['route'] . '"> ' . $rows1['route'] .     '</option>';  

                }

            }   


         echo '</select>
                            </td>


                    <td style="width:200px" id="CPH_GridView1_Status1'.$rows['net_id'].'" class="edit2 status1 '.$rows["net_id"].' "><input type="checkbox" style="margin:0 0 0 93px;" name=""/></td>

ajax

<script>

  $(document).ready(function(){

        $('.edit1').on('change', function(){


                                     arr = $(this).attr('class').split( " " );
                                     var clientid=document.getElementById("client").value;
                                     account_id=document.getElementById("account_id").value;


                                        $.ajax({    type: "POST",
                                                    url:"clientnetworkpricelist/routestatusupdate.php",
                                                    data: "value="+$(this).val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid+"&account_id="+account_id,


                                                    success: function(res){
                                                         data = jQuery.parseJSON(res); //added line
                                                         alert('Saved Successfully!');
                                                         $('#CPH_GridView1_Status'+arr[2]).empty();
                                                         $('#CPH_GridView1_Status'+arr[2]).append(data.status);
                                                         $('.ajax').html($(this).val());
                                                         $('.ajax').removeClass('ajax');
                                                    }});


                                  }  


                         );


     });


</script>
  • 写回答

1条回答 默认 最新

  • douti6740 2014-01-19 06:41
    关注

    To check the checkbox in the next td try

    $(this).parent().next().find('input:checkbox').attr("checked",true);
    

    Jsfiddle

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作