日期:2014-05-17 浏览次数:20548 次
<?php
//test.php
if(isset($_GET['commit'])){
$res1 = mysql_query('COMMIT');
}
if(isset($_GET['rollback'])){
$res2 = mysql_query('ROLLBACK');
}
?>
<?php if(!empty($res1)){ ?>
<table>COMMIT</table>
<?php } ?>
<?php if(!empty($res2)){ ?>
<table>ROLLBACK</table>
<?php } ?>
<form name="form" action="" method="post">
<input type="button" name="commit" value="确认" onclick="a()"/>
<input type="button" name="rollback" value="放弃" onclick="b()"/>
</form>
<script language="JavaScript" type="text/javascript">
function a(){
document.form.action="test.php?commit=ok";
document.form.submit();
}
function a(){
document.form.action="test.php?rollback=ok";
document.form.submit();
}
</script>
------解决方案--------------------
方法错了,你把mysql的事务分拆给了两次请求,肯定行不通的
你需要实现的效果是啥?
------解决方案--------------------
<form action='' onsubmit="subCheck()">
...
function subCheck(){
var nm = document.getElementById("nameTest");
if(nm.value!="")
return true;//返回true才提交
return false;
}
------解决方案--------------------
不需要跳转的话那就用ajax请求服务器吧。