所以这就是我面临的问题。非常感谢任何帮助。
我有一个包含文本框和提交按钮的表单。 process-page.php有一个php脚本,用于检查我的数据库中的用户信息,并返回处理过的数据。
<form id="myform" aciton="process-page.php" method="post">
<input type="text" id="checkinfo" name="checkinfo" />
<input type="submit" value="check info" id="submit" />
</form>
现在,当用户在文本框中输入信息并单击提交按钮时,我使用ajax将信息发送到process-page.php并显示数据而无需加载页面。
我使用ajax返回的数据也包含一个sumit按钮(付款按钮)。
这是我从process-page.php获得的回复
//html information along with payment button.
<h2>The user is currently available. Make a payment to join hands with the user.</h2>
<input type="submit" id="payment" value="make payment" />
问题是,我有2个提交按钮,一个文本框旁边有一个表单action =“process-page.php”,另一个提交按钮(付款按钮)是从进程页面获得的响应.PHP
现在我要做的是,在jquery的帮助下,我需要在用户提交表单时隐藏提交按钮。
此代码是否有效?
$("#myfrom").submit(function(){
//perform validation so that no numbers are entered.
if(does not match){
alert();
return false;
}
//THe above performs the validation
Now is this the correct method to hide submit button?
if(true){
$("submit").hide();
}
});
我想知道这是否是在执行验证时隐藏提交按钮的正确方法,如果所有内容都经过验证,则表单已提交,然后隐藏提交按钮。
现在我会得到另一个提交按钮(付款按钮),我希望像这样更改表单操作atrribute。
<form id="myform" aciton="make-payments.php" method="post">
Does, using this code works?
$("#form").attr('action', 'make-payments.php');
这会改变行动归因吗?帮助我。
答案 0 :(得分:0)
不,您的隐藏按钮代码字符串将无法正常工作。
检查jQuery selectors,您使用了错误的选择器
现在你正在使用元素选择器,所以所有提交元素(你都没有BTW),你必须使用id选择器。
这将有效:
$("#submit").hide();