Javascript 如何禁用提交按钮是获取方法?
我想搜索狗,所以当我点击提交按钮的网址看起来像http://localhost/myproject/search.php?q=dog&submit= 我想禁用提交按钮,它将显示URL导航http://localhost/myproject/search.php?q=dog. 我的代码-Javascript 如何禁用提交按钮是获取方法?,javascript,php,jquery,query-string,Javascript,Php,Jquery,Query String,我想搜索狗,所以当我点击提交按钮的网址看起来像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.
<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=" " style="cursor:pointer;" class="search_btn" />
</td>
</tr>
</table>
</form>
请帮助我如何禁用URL导航中的提交按钮
如果有jquery或javascript代码,请在下面发布您的答案
搜索图像截图
不要给提交按钮赋予名称属性。删除提交按钮中的名称属性
<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=" " style="cursor:pointer;" class="search_btn" />
</td>
</tr>
</table>
</form>
除了昆廷:
使用GET方法时,查询字符串通过“name=value”表单中的URL发送到服务器。因此,如果不想在URL中显示提交,请从提交中删除“name”属性。
如果您不想通过URL发送查询字符串,可以使用$\u POST方法。试试以下方法:
在这里,您可以在表单标记中设置method=post或
从“提交”按钮的属性中删除名称。
如果要使用输入类型submit name自定义代码,可以使用javascript或jquery 代码:
window.location='/search.php?q='+qvariable;
否则,请删除input type=submit中的name属性
<input type="submit" id="button" value=" " style="cursor:pointer;" class="search_btn" />
为什么提交按钮的值是一个不间断的空格?人们怎么知道它是做什么的?加上残疾人button@SridharR-这将阻止它被用于提交表单。Ohk然后使用“遵循我的第二个建议”并从“提交”按钮中删除名称。我想使用“表单提交”按钮。谢谢,我找到解决办法了。谢谢你的帮助。