1、freemarker word复选框动态生成
<w:t> <#list CHECK_RESULT_LIST! as result> <#if result.IS_CHECKED == "Y"> <w:sym w:font="Wingdings" w:char="F0FE"/>${result.DATA_VALUE!""} <#else> □${result.DATA_VALUE!""} </#if> </#list> </w:t>
2、freemarker word判断返回值的长度是否大于0
<w:t> <#if (expert.TITLE_LEVEL_VALUE)?length gt 0> ${expert.TITLE_LEVEL_VALUE!""}、${expert.EXPERT_DUTY!""} <#else> ...... </#if> </w:t>
3、动态循环生成的input,输入时动态计算(jsp)
<input type="text" id="targetFloatId${target.PK_EVA_TARGET}" name="EVA_TARGET_SCORE_${target.PK_EVA_TARGET}" class="form-control total" value="${target.EVA_TARGET_SCORE}" style="width: 40%; " οnchange="sumScore()" οnblur="checkScore(this,'${target.PK_EVA_TARGET}');">
var sumScore = 0; $(".total").each(function () { sumScore += parseFloat($(this).val()); //console.info() }) $("#total").val(sumScore);
4、复选框,全选,全不选,
<input type="checkbox" id="selectAll" name="selectAll" οnclick="selectAll()">//全选、全不选
<input type="checkbox" id="selectOne${obj.PK_CLOSURE}" name="selectOne" value="${obj.PK_CLOSURE}" οnclick="selectOne(${obj.PK_CLOSURE},this)">//选择一条
//全部选中 function selectAll() { console.info("点我了") if ($("#selectAll").is(':checked')) { $(":checkbox[name='selectOne']").prop("checked", true); } else { $(":checkbox[name='selectOne']").prop("checked", false); } } //选择一条 function selectOne(closureId) { console.info(closureId) var i = 0; $("input[name='selectOne']").each(function(item,index){ if($(this).is(":checked")) { i++; } }); if (i>0){ if ($(":checkbox[name='selectOne']").toArray().length==i){ $(":checkbox[name='selectAll']").prop("checked", true); }else{ $(":checkbox[name='selectAll']").prop("checked", false); } }else{ $(":checkbox[name='selectAll']").prop("checked", false); } }
5、根据返回值选中 select中的option(jsp)
<select id="editTargetSystemCategoryId" name="targetSystemCategory" title="指标体系类别" class="form-control td_inline_dialog required"> <option value="-1">---请选择---</option> <option value="P">验收评审指标</option> <option value="C" selected="selected">项目评审指标</option> </select>
var options = $("#targetSystemCategoryId").find("option"); for (var i = 0;i < options.length;i++){ if ($(options[i]).val() == '${targetSystemCategory}'){ $(options[i]).prop("selected","selected"); } }
6、获取单选按钮选中的值
var xxx= $("input[name=' ']:checked").val();
7、根据返回值,选中单选按钮
$("input[name= ][value='"+xxx+"']").prop("checked",true);
8、FreeMarker复选框
<#list CHECK_RESULT_LIST! as result> <w:r> <w:rPr> <w:rFonts w:ascii="仿宋_GB2312" w:fareast="仿宋_GB2312"/> <wx:font wx:val="仿宋_GB2312"/> <w:sz w:val="24"/> <w:sz-cs w:val="24"/> </w:rPr> <#if result.IS_CHECKED == "Y"><w:t> </w:t><w:sym w:font="Wingdings 2" w:char="0052"/> <#else><w:t> □</w:t> </#if> </w:r> <w:r> <w:rPr> <w:rFonts w:ascii="仿宋_GB2312" w:fareast="仿宋_GB2312"/> <wx:font wx:val="仿宋_GB2312"/> <w:sz w:val="24"/> <w:sz-cs w:val="24"/> </w:rPr> <w:t>${result.DATA_VALUE!""}</w:t> </w:r> </#list>
注意:<w:t> </w:t>不要把<w:sym w:font="Wingdings 2" w:char="0052"/>包住,否则WPS打开不选中