Codeigniter:删除或更改表单按钮样式
我正在使用 Codeigniter 构建表单。
提交按钮是:
echo form_submit('submit', 'Buy it', "id='bred'");
现在我正在同一个 php 文件中处理表单:
if (isset($_POST['submit'])) {
$query = "INSERT INTO table (product, price) VALUES ('$product', '$price')";
mysql_query($query)
or die(mysql_error());
//after inserting in the database I need to delete the submit button, so the form cannot be submitted twice
}
插入数据库后,我需要删除/将 css 更改为不透明度 0/更改 css 以不显示提交按钮,因此表格不能提交两次。
我该怎么做?
谢谢
I'm using Codeigniter to build a form.
The submit button is:
echo form_submit('submit', 'Buy it', "id='bred'");
Now I'm processing the form in the same php file that it is:
if (isset($_POST['submit'])) {
$query = "INSERT INTO table (product, price) VALUES ('$product', '$price')";
mysql_query($query)
or die(mysql_error());
//after inserting in the database I need to delete the submit button, so the form cannot be submitted twice
}
After inserting in the database I need to delete/change the css to opacity 0/change the css to display none the submit button, so the form cannot be submitted twice.
How can I do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了你所做的方式不保存:
由于“回显”按钮,您无法使用 PHP 删除它。
一种(不是很时尚)的方法是回显一些删除按钮的 JS 代码。
Except that the way you do isn't save:
Due to "echo" the button you have no possibility to delete it with PHP
A (not very stylish) way would be to echo some JS code that deletes the button.
使用 jQuery 将使这对您来说变得容易。
您需要检测表单的提交,然后禁用提交按钮。
此代码假定您的表单和按钮分别具有 ID 'myForm' 和 'submitButton'。
JavaScript:
Making use of jQuery will make this easy for you.
You will need to detect the submission of the form and then disable the submit button.
This code assumes that your form and button have the IDs 'myForm' and 'submitButton' respectively.
Javascript: