<script type="text/javascript">
function auth(obj) {
if (confirm("Do you really want to authenticate this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='auth';
obj.form.submit();
}
return false;
}function reject(obj) {
if (confirm("Do you really want to reject this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='reject';
obj.form.submit();
}
return false;
}
</script>
<form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post">
<input type="hidden" name="method" value="" id="method"/>
<input type="submit" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/> <input type="submit" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/></form>
为什么在方法里写的return false,弹出confirm对话框 点取消button ,还是会刷新页面呢
function auth(obj) {
if (confirm("Do you really want to authenticate this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='auth';
obj.form.submit();
}
return false;
}function reject(obj) {
if (confirm("Do you really want to reject this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='reject';
obj.form.submit();
}
return false;
}
</script>
<form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post">
<input type="hidden" name="method" value="" id="method"/>
<input type="submit" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/> <input type="submit" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/></form>
为什么在方法里写的return false,弹出confirm对话框 点取消button ,还是会刷新页面呢
<input type="hidden" name="method" value="" id="method"/>
<input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/> <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form>
return reject(this)return 怎么能少呢?
<script type="text/javascript">
function auth(obj) {
if (confirm("Do you really want to authenticate this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='auth';
obj.form.onsubmit=true;
obj.form.submit();
}} function reject(obj) {
if (confirm("Do you really want to reject this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='reject';
obj.form.onsubmit=true;
obj.form.submit();
}}
</script>
<form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post">
<input type="hidden" name="method" value="" id="method"/>
<input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/> <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form>
function auth(obj) {
if (confirm("Do you really want to authenticate this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='auth';
obj.form.submit();
}} function reject(obj) {
if (confirm("Do you really want to reject this employee?")) {
obj.setAttribute('disabled', 'true');
document.getElementById('method').value='reject';
obj.form.submit();
}}
</script>
<form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post">
<input type="hidden" name="method" value="" id="method"/>
<input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/> <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form> 不好意思上面的有问题!
顶个~~submit是根据返回值判断执行的