2013-02-08 84 views
1

我想在動作類,我設置訪問複選框值在JavaScript複選框值Struts 2的

<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(); 
} 

當我嘗試訪問它在行動類像下面我得到空

public MDesig mstDesignations=new MDesig(); 

System.out.println("Is Active value:::" +mstDesignations.getIsActive()); 

回答

0

您需要更改javascr ipt按名稱分配字段的值。假設designationForm是表單名稱,mstDesignations.isActive是字段名稱。

this.designationForm['mstDesignations.isActive'].value=1;