1

我想访问我在 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());
4

1 回答 1

0

您需要更改 javascript 以按名称分配字段的值。AssumeddesignationForm是表单名称,并且mstDesignations.isActive是字段名称。

this.designationForm['mstDesignations.isActive'].value=1;
于 2013-02-08T09:43:02.150 回答