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 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c