我想觸發按鈕上的js函數onClick。出於某種原因,我面臨的功能未定義。如何在JSP中的onClick(button)上調用Java腳本函數?
需要在JSP
// doUpdate function details
boolean doUpdate = request.getParameter("update")!=null;
String stateButton = request.getParameter("update");
if (doUpdate && catalogID != null && companyID != 0) {
if(catalogManager!=null) {
boolean success = catalogManager.updateStatus(new Integer(catalogID).intValue(),user, stateButton);
if((stateButton.equals("Active")) && success) {
%>
<span class="TitleLevel01"><font color=green>Catalog is Activated.</font></span>
<%
}
if((stateButton.equals("Active")) && !success) {
%>
<span class="TitleLevel01"><font color=red>Cannot activate subcatalog with Inactive parent.</font></span>
<%
}
if(!stateButton.equals("Active")) {
%>
<span class="TitleLevel01"><font color=green>Catalog is Deactivated.</font></span>
<%
}
}
}
於這種形式稱之爲(),這樣,
<form name="maintain_catalog_frm" id="maintain_catalog_frm" >
<input type=hidden name="PID" value="">
<input type="submit" name="update" value="Inactive" onClick="return doUpdate(document.maintain_catalog_frm);" >
</form>
你也可以貼出JavaScript函數嗎? – MilkyWayJoe