weixin_33681778 2014-07-21 17:11 采纳率: 0%
浏览 28

将代码分配给特定形式

I am trying to submit a variable on form1 using jquery which at the end disables the submit button for this form with a message "Sent Successfully".

There's another form on the page called form2 which is assigned an action to submit variables to another page without ajax call but i think my button disable code is conflicting with the form2 not making it able to send the variables to the assigned action page.

<script language="javascript">
/**
 * Disable submit button
 */
$(function(){
      $('input:submit', '#form1').click(function(){
            $(this).val('Sent Successfully...');
            $(this).attr('disabled', 'disabled');
      });
});
</script>

form2

<form id="form2" name="form2" method="post" action="search.php">
          <label for="textfield"></label>
          <input type="text" name="textfield" id="textfield" />
          <input type="submit" name="button2" id="button2" value="Submit" />
        </form>
  • 写回答

4条回答 默认 最新

  • weixin_33724046 2014-07-21 17:13
    关注

    yes it deflects because you're using two selectors, one that will disable all the submit buttons and then #form1. try changing it to:

    $(function(){
          $('#form1').click(function(){
                $(this).val('Sent Successfully...');
                $(this).attr('disabled', 'disabled');
          });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表
  • ¥15 DbVisualizer Pro 12.0.7 sql commander光标错位 显示位置与实际不符