【问题标题】:How to disable Submit button is get method?如何禁用提交按钮是get方法?
【发布时间】:2013-11-01 06:34:24
【问题描述】:

我想搜索狗,所以当我点击提交按钮时,URL 看起来像 http://localhost/myproject/search.php?q=dog&submit= 我想禁用提交按钮是 URL 导航,它将看起来像 http://localhost/myproject/search.php?q=dog

我的代码 -

<form id="formSearch" name="formSearch" method="get" action="search.php">
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
           <td width="67%" align="right" valign="top">                      
              <input type="text" name="search" id="search" class="search_text_box" placeholder="Search" autocomplete="off"/>
           </td>
           <td width="33%" align="left" valign="top">
              <input type="submit" name="submit" id="button" value="&nbsp;" style="cursor:pointer;" class="search_btn" />
           </td>
        </tr>
      </table>
</form>

请帮助我如何禁用 URL 导航中的提交按钮?

如果有任何 jquery 或 javascript 代码,请在下面发布您的答案

搜索图片截图

【问题讨论】:

  • 为什么提交按钮的值是不间断空格?人们应该如何知道它的作用?
  • 在按钮中添加禁用
  • @SridharR — 这将阻止它被用于提交表单。

标签: javascript php jquery query-string


【解决方案1】:

不要给提交按钮一个名称属性。

【讨论】:

  • 感谢您的帮助。
【解决方案2】:

删除提交按钮中的名称属性

<form id="formSearch" name="formSearch" method="get" action="search/">
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
           <td width="67%" align="right" valign="top">                      
              <input type="text" name="search" id="search" class="search_text_box" placeholder="Search" autocomplete="off"/>
           </td>
           <td width="33%" align="left" valign="top">
              <input type="submit" id="button" value="&nbsp;" style="cursor:pointer;" class="search_btn" />
           </td>
        </tr>
      </table>
</form>

【讨论】:

    【解决方案3】:

    加入昆汀:

    当您使用 GET 方法时,查询字符串会通过 URL 以“name=value”形式发送到服务器。因此,如果您不想在 URL 中显示提交,则可以从提交中删除“name”属性。 如果您不想通过 URL 发送查询字符串,则可以使用 $_POST 方法。

    【讨论】:

      【解决方案4】:

      如果您想自定义输入类型提交名称的代码,您可以使用 javascript 或 jquery

      代码:

      window.location='/search.php?q='+qvariable;
      

      否则删除输入 type=submit 中的 name 属性

      <input type="submit" id="button" value="&nbsp;" style="cursor:pointer;" class="search_btn" />
      

      【讨论】:

        【解决方案5】:

        试试这个:

        • 这里可以在表单标签中设置method="post"或者
        • 从提交按钮的属性中删除名称。

        【讨论】:

        • 哦,然后按照我的第二个建议使用并从提交按钮中删除名称。
        • 我想形成提交按钮。谢谢我的解决方案。
        猜你喜欢
        • 2015-11-10
        • 1970-01-01
        • 1970-01-01
        • 2015-10-08
        • 2013-10-02
        • 1970-01-01
        • 1970-01-01
        • 2022-10-22
        • 1970-01-01
        相关资源
        最近更新 更多