admin 管理员组文章数量: 1086019
I am working on development of an application using CakePHP framework.
We all have clients that click several times on the submit button.
How can I hide or (even better) disable the submit button when a user clicks on it?
On the internet I found several Javascripts that can do it, but I need help to integrate it into my CakePHP script.
I am working on development of an application using CakePHP framework.
We all have clients that click several times on the submit button.
How can I hide or (even better) disable the submit button when a user clicks on it?
On the internet I found several Javascripts that can do it, but I need help to integrate it into my CakePHP script.
Share Improve this question edited Sep 26, 2010 at 16:48 Marcel Korpel 21.8k6 gold badges62 silver badges80 bronze badges asked Sep 26, 2010 at 15:10 user198003user198003 11.2k30 gold badges98 silver badges153 bronze badges4 Answers
Reset to default 7Put this on the submit button:
onclick="this.disabled=true;return true;"
example
<input type=submit value='submit'
onClick='this.disabled=true;doSection(loading);return true;'>
using jquery
$("form").submit(function() {
$(":submit", this).attr("disabled", "disabled");
});
To follow up on what JapanPro said, if you want to place an onClick event in your submit field then you will need to use the form helper's submit function instead of the end() function. (CakePHP 1.2)
<?php echo $form->submit('Submit', array('onClick' => 'alert("Test");')); ?>
This also means you will need to manually close the form.
</form>
Id remend using jQuery to handle this
Try:
<input data-disable-with="Saving..." name="mit" type="submit" value="Create new item">
Note the
data-disable-with="Saving..."
I've tried every suggestion on the web, including the ones above, and this is the only thing that seems to work on all browsers. I'm using CakePHP 1.2.
echo $form->submit('Submit', array('onClick' => 'this.disabled=true;this.form.submit();return true;'));
Hope this helps.
本文标签: javascriptHide (or disable) submit button when user clicks on itStack Overflow
版权声明:本文标题:javascript - Hide (or disable) submit button when user clicks on it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744025757a2520599.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论