function addDev()
{
var sFeatures="dialogWidth:700px;dialogHeight:500px;scroll:no;";
var customerId = document.all['cusId'].value;
var result= window.showModalDialog('<%=appURL %>/businesspermit/DeviceSelectAction.do?formAction=toAddPage&customerId='+customerId,"",sFeatures);
if(result!=null )
{
<logic:present name="edit" scope="request">
document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=toEditBusi&showType=1";
</logic:present>
<logic:notPresent name="edit" scope="request">
document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=getBusinessSet";
</logic:notPresent>
// window.location.reload();
CustomerSetForm.submit();
}
}
這個函數表示:添加新的設備JS函數,window.showModalDialog()會返回一個值result,如果result!=null,則刷新這個頁面。
原來是用window.location.reload();刷新頁面的,但是這樣就不能保留之前頁面上輸入的數據,為了保留原來輸入的數據,換成了
document.CustomerSetForm.action=“”;
CustomerSetForm.submit();
上面的語句表示:讓這個頁面重新指向另一個action地址,然后提交。這樣,用了Struts標簽后,以前四輸入的數據仍然會保留到返回后的頁面了。
注意:在js代碼中,可能使用譬如說<logic:present>等標簽。