2016-04-08 21 views
-1

的形式創建取消按鈕我需要在JSP代碼中的表單中放置「保存」和「取消」功能。點擊「保存」應提交表單數據到預定的地方。點擊「取消」應取消表單,而不提交數據到指定地點。JSP/HTML/JS/CSS - 如何以

感謝&問候,

阿倫Dhwaj

+0

請提供一個** [MCVE(http://stackoverflow.com/help/mcve)**,然後讓我們來看看它的相關性,以你的問題 – AGE

+0

提供代碼,以及javascript和jquery如何與您的問題相關? –

回答

0

我已經解決了這個以下列方式:

1)myInfo.jsp

<form name="myForm" action="/done" method="POST"> 
<fieldset> 
    <label>Enter new name </label> 
    <input class="form-control" name="edit_filed" id="name_edit" type="text" value="${obj.getfName()} &nbsp;${obj.getlName()}"> 

    <label>Enter new specializations </label> 
    <input class="form-control" name="specializations" id="specializations_edit" type="text" value="${obj.oldSpecialization()}"> 

    <button class="btn btn-success" onClick="Save('myInfo_visual', 'myInfo_edit')">Save</button> 
    <input type="button" value="Cancel" class="btn btn-gray" onClick="Cancel('myInfo_visual', 'myInfo_edit')"/> 
</fieldset> 

2)myInfo.js

function Save(visual, edit) 

{
變種V =的document.getElementById(目測); var e = document.getElementById(edit);

v.style.display="block"; 
e.style.display="none"; 

}

功能取消(視覺,編輯) { 變種V =的document.getElementById(目測); var e = document.getElementById(edit);

v.style.display="block"; 
e.style.display="none"; 

return false; 

}

+0

重要的一點是:「返回false」。在取消功能。 –