Html 如何从表单提交中删除“提交查询”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1625287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove 'submit query' from a form submit?
提问by Zach Smith
I have an html form and the submit button says "submit query". How can I remove this text? I am using a background image for the submit button and this text is messing up the button :( Any help would be greatly appreciated.
我有一个 html 表单,提交按钮显示“提交查询”。如何删除此文本?我正在为提交按钮使用背景图像,并且此文本弄乱了按钮:( 任何帮助将不胜感激。
回答by Brandon
If you do not give your submit button a value
如果你没有给你的提交按钮一个值
<input type="submit" />
instead of something like
而不是像
<input type="submit" value="Submit" />
it will display 'submit query' by default. Try giving it a space
as the value.
默认情况下,它将显示“提交查询”。尝试给它一个空格
作为值。
回答by tahdhaze09
use:
用:
<input type='submit' name='btnTest2' value=''>
Leave the value blank and there will be no words on the button. Since you're using a background image a for the button, give the button a height and width, otherwise it will display as a small gray blip (because there are no words on the button).
将该值留空,按钮上将没有文字。由于您为按钮使用了背景图像 a,因此请为按钮指定高度和宽度,否则它将显示为一个小的灰色 blip(因为按钮上没有文字)。
回答by J.Hendrix
You just have to give it a value:
你只需要给它一个值:
<input type='submit' name='btnTest'>
<input type='submit' name='btnTest2' value='Push Me'>
In the example above, btnTest
renders as "Submit Query" while btnTest2
renders as "Push Me". Hope this helps.
在上面的示例中,btnTest
呈现为“提交查询”而btnTest2
呈现为“推送我”。希望这可以帮助。
UPDATE:You can do this to not display any text.
更新:您可以这样做以不显示任何文本。
<input type='submit' name='btnTest2' value='' style="width:100px;">
回答by Quentin
Background images are not content. If you want to use an image to tell people what a submit button will do, use a real image. As a bonus that allows you to provide alternative text for users who cannot see the image (e.g. because it failed to load or because they are blind).
背景图像不是内容。如果您想使用图像告诉人们提交按钮的作用,请使用真实图像。作为奖励,您可以为无法看到图像的用户提供替代文本(例如,因为无法加载或因为他们是盲人)。
<button type="submit">
<img src="example.png" alt="Submit">
</button>
回答by Hatem Ahmed
Just use the value attribute as shown below:
只需使用 value 属性,如下所示:
<input value="Whateveryouwant" type="submit">
回答by FelicianoTech
Not sure if this was relevant then, but we would use type="image" rather than type="submit"
不确定这是否相关,但我们会使用 type="image" 而不是 type="submit"
回答by Paula C
Unfortunately, this does not work, at least not in a CMS. I've tried the space and the
but IE8 will not recognize it. If I put the same in the value, it reverts back to 'Submit Query'. Just updating for anyone else who finds this method through a search.
不幸的是,这不起作用,至少在 CMS 中不起作用。我已经尝试了空间,
但 IE8 无法识别它。如果我将相同的值放入值中,它会恢复为“提交查询”。只需为通过搜索找到此方法的其他人更新。
EDIT :I added text indent: -9999px;
to my CSS, and it seems that it worked. I still added the space in the value attribute for good measure.
编辑:我添加text indent: -9999px;
到我的 CSS,它似乎工作。我仍然在 value 属性中添加了空格以获得良好的度量。
回答by Noosa
Just put a space between the value quotes. Simple fix.
只需在值引号之间放置一个空格。简单的修复。
Readthe question beforeyou reply. You may actually help someone.
在回答之前阅读问题。你实际上可能会帮助某人。
回答by Jaime
I had this issue as well. If you don't set a value for a submit button it defaults to "Submit Query". I assume you are using an image for your submit button since you have the default value.
我也有这个问题。如果您没有为提交按钮设置值,则默认为“提交查询”。我假设您使用图像作为提交按钮,因为您具有默认值。
If you want to fix it for IE8 add a text indent using CSS which will push the default value off the screen.
如果您想为 IE8 修复它,请使用 CSS 添加文本缩进,这会将默认值从屏幕上移开。
text-indent:9999px;
If you want to fix it for IE9 you also need to change the default value because the text-indent doesn't work :( in your submit button add the following:
如果您想为 IE9 修复它,您还需要更改默认值,因为文本缩进不起作用 :( 在您的提交按钮中添加以下内容:
value=" "
I found this to work without a non-breaking space and tested it to my satisfaction on the IE's on browserstack. If you want to use the breaking space, feel free; I'll include the code.
我发现它可以在没有不间断空间的情况下工作,并在浏览器堆栈上的 IE 上对其进行了测试,令我满意。如果您想使用休息空间,请随意;我将包括代码。
value=" "
Also, thank you to the other stack-responders, you helped me fix this issue on IE9.
另外,感谢其他堆栈响应者,您帮助我解决了 IE9 上的这个问题。
Also you inspired me to post my findings here and possibly help others!
你也激励我在这里发布我的发现,并可能帮助其他人!
回答by LukeP
If you are using something like a jQueryUI dialog button then you do not want to have the input button show up in the form, but rather just have it in the footer of the dialog. I accomplished this by doing the following:
如果您使用的是 jQueryUI 对话框按钮之类的东西,那么您不希望输入按钮显示在表单中,而只是将其显示在对话框的页脚中。我通过执行以下操作来完成此操作:
Because IE will automatically put in an <input type="submit" />
I put this in the form instead: <input type="submit" style="display:none" />
因为 IE 会自动放入一个<input type="submit" />
我把它放在表单中:<input type="submit" style="display:none" />
Then later in the dialog JavaScript I put:
然后在对话框 JavaScript 中我放了:
$("#register-dialog").dialog({
title: "Register",
modal: true,
width: 700,
buttons: {
Register: function () {
$('#registrationForm').submit();
},
Close: function () {
$(this).dialog("close");
}
}
});