我想访问我在javascript中设置的动作类中的复选框值
<s:checkbox key="mstDesignations.isActive" id="isActive"></s:checkbox>
<button type="button" class="submitBtn" onclick="adddesignation()"></button>
的javascript:
function adddesignation() {
if(document.designationForm.isActive.checked==true){
document.designationForm.isActive.fieldValue=1;
}
else if( document.designationForm.isActive.checked==false)
{
document.designationForm.isActive.fieldValue=2;
}
alert(document.designationForm.isActive.fieldValue);
document.designationForm.submit();
}
当我尝试在下面的动作类中访问它时,我得到null
public MDesig mstDesignations=new MDesig();
System.out.println("Is Active value:::" +mstDesignations.getIsActive());
答案 0 :(得分:0)
您需要更改javascript以按名称分配字段的值。假设designationForm
是表单名称,mstDesignations.isActive
是字段名称。
this.designationForm['mstDesignations.isActive'].value=1;