最近搜索

layui 监听 单选按钮, 点击 事件。

浏览:174
管理员 2024-03-31 11:55



function  load_data(){
   console.log(`${biaozhun}  ${guige}`);
   $.post("/admin/price/sheet/search", {biaozhun:biaozhun,guige:guige
   }, function(result) {
      if (result.success) {
         $("#head_title").html(result.priceSheetHead.title+"的价格表");
         result.priceSheetHeadList.forEach((priceSheetHead)=>{
            let isChecked = result.priceSheetHead.id === priceSheetHead.id ? 'checked' : '';
            //result.priceSheetHead.id==priceSheetHead.id  弄一个checked  如果不相等 就不弄。咋 写
            $("div#priceSheetHeadList").append('<input type="radio" name="priceSheetHeadId" value="'+priceSheetHead.id+'" '+isChecked+' title="'+priceSheetHead.title+'"  >');
         });
         w_form.on('radio', function(data){
            console.log(data.elem.name); // 得到单选按钮的name属性
            console.log(data.value); // 得到被选中的值
            console.log(data.elem.title); // 得到被选中的单选按钮的显示标题
         });
         w_form.render(); //更新全部表单
         result.priceSheetList.forEach((priceSheet)=>{
             $("table#priceSheetList tbody ").append("<tr>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.biaoZhun.bianhao+"</td>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.biaoZhun.biaozhun+"</td>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.biaoZhun.guige+"</td>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.type+"</td>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.price+"</td>\n" +
                   "\t\t\t\t\t<td>"+priceSheet.priceSheetHead.title+"</td>\n" +
                   ' <td>  <button type="button" onclick="select(\''+priceSheet.id+'\')" class="layui-btn layui-btn-xs">选择</button></td> ' +
                   "</tr>");

         });
         // map.put("priceSheetList", priceSheetList);
         // map.put("priceSheetHead", priceSheetHead);
         // map.put("priceSheetHeadList", priceSheetHeadList);
      } else {
         layer.msg(result.msg);
      }
   }, 'json');
}


image.png





联系站长

站长微信:xiaomao0055

站长QQ:14496453