由于没有指定,这里有一个简单的方法来做到这一点没有jQuery的。根据浏览器的兼容性,您可能需要以不同方式附加事件侦听器,但一般概念是相同的。
HTML
<form name="myForm" action="invoiceCreate.php" method="post">
<input type="checkbox" name="business" id="business" vaulue="yes" />
</form>
的Javascript
var form = document.getElementsByName("myForm")[0];
var checkBox = document.getElementById("business");
checkBox.onchange = function(){
if(this.checked){
form.action = "giveEmTheBusiness.php";
}else{
form.action = "invoiceCreate.php";
}
console.log(form.action);
};
或类似的,一个事件绑定到submit
form.onsubmit = function(){
if(checkBox.checked)
form.action = "giveEmTheBusiness.php"
else
form.action = "invoiceCreate.php";
};
EXAMPLE
使用javascript。你尝试过什么吗? – aleation 2013-04-04 15:39:31
不这样做。改为使逻辑分支决策服务器端。 – Quentin 2013-04-04 15:43:07