[英]JSP/HTML / JS / CSS - How to create a cancel button in form
我需要將“保存”和“取消”功能放入JSP代碼的表單中。 單擊“保存”應將表單數據提交到預期的位置。 單擊“取消”應取消表格,而無需將數據提交到預期的位置。
感謝和問候,
阿倫·達瓦(Arun Dhwaj)
我已經通過以下方式解決了這個問題:
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()} ${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)
{
var v = document.getElementById(visual); var e = document.getElementById(edit);
v.style.display="block";
e.style.display="none";
}
函數Cancel(可視,編輯){var v = document.getElementById(visual); var e = document.getElementById(edit);
v.style.display="block";
e.style.display="none";
return false;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.