前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >freemaker页面复选框全选与反选

freemaker页面复选框全选与反选

作者头像
六月的雨在Tencent
发布2024-03-28 19:08:53
510
发布2024-03-28 19:08:53
举报
文章被收录于专栏:CSDNCSDN
代码语言:text
复制
                <tr>  
                    <td align="right" style="width:120px">  
                       <input type="checkbox" class="chk_list"    id="checkall" checked="checked" value="" >  
                       <td>全选/取消全选</td>  
                    </td>  
                </tr>  
                 <#if partnerFieldList?exists>  
                     <#list partnerFieldList as partnerField>  
                       <tr>  
                      <td align="right" style="width:120px"><input type="checkbox" checked="checked" id="   fieldNames" name="fieldNames" value="${partnerField.name}" /></td>  
                      <td style="width:150px">  
               ${partnerField.description}  
                  </td>  
                  <#if fieldTypeList?exists>  
                  <td style="width:150px">  
                   <select id="fieldType" name="fieldType" class="cword chosen">  
                     <#list fieldTypeList as fieldType>  
                                       <option value="${fieldType.id}">${fieldType.name}</option>  
                                       </#list>  
               </select>  
                  </td>  
                  </#if>  
                       </tr>  
                      </#list>  
                 </#if>  
   js实现:  
     $(function(){  
      $('#partnerFieldAddForm').Validform({  
       btnSubmit:"#saveBtn",  
       tiptype:2,  
       showAllError:true,  
       beforeSubmit: function(){  
       var ids = "";  
          var selectedCheckboxs =$("input:checked[name='fieldNames']");  
          $.each(selectedCheckboxs, function(index, value){  
             ids += $(value).val() +',';  
           var value =  $(value).val()+'|'+$(value).parent().next().next().children().val();  
           $(this).val(value);  
          })  
       ids = ids.substring(0, ids.length - 1);  
                if (ids.length == 0) {  
                   $.jBox.tip('请先选择一行数据!');  
                   return false;  
                }  
       }  
      });  
      $(   "#checkall").click(  
        function(){  
        if(this.checked){  
           $("input[name='   fieldNames']").attr('checked', true)  
        }else{  
           $("input[name=   'fieldNames']").attr('checked', false)  
            }  
        }  
        );  
      $('.chosen').chosen({  
       "no_results_text":'未找到匹配数据!',  
       "width":"120px",  
       "allow_single_deselect":true  
      });  
      $('#cancelBtn').click(function(){  
       parent.jBox.close(true);  
      });  
     });  
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2024-03-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档