PHP/Javascript复选框,可在选中时更改表单操作 [英] PHP/Javascript Checkbox to change form action when checked

查看:44
本文介绍了PHP/Javascript复选框,可在选中时更改表单操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我得到的:

<form action="invoiceCreate.php" method="post">
<input type="checkbox" name="business" id="business" vaulue="yes" />

基本上,当我选中"business" 复选框时,我希望将表单操作更改为 BusinessInoiveCreate.php 而不是 InvoiceCreate.php

Basically when I check the "business" checkbox, I want the form action to change to BusinessInoiveCreate.php instead of InvoiceCreate.php.

这样做的最好方法是什么?

What would be the best way to do so?

推荐答案

$('#business').on('change', function(){
    if ($(this).is(':checked')) {
        $('form').attr('action', 'BusinessInoiveCreate.php');
    } else {
        $('form').attr('action', 'invoiceCreate.php');
    }
});

正在运行的演示: http://jsfiddle.net/eV7vY/

这篇关于PHP/Javascript复选框,可在选中时更改表单操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆