[英]html how to make “input” text is different from value passing to server
Could someone please tell me whether there is a way to differentiate the text showing on the input button and the value it will pass into server when click the button. 有人可以告诉我是否有一种方法可以区分输入按钮上显示的文本以及单击按钮时它将传递给服务器的值。
For example, I have a input button, when it is clicked, I would like it to pass "100" into server (I just set value = 100), but instead of showing me "100" on the button, I would like it to show "200". 例如,我有一个输入按钮,当我单击它时,我希望它将“ 100”传递到服务器(我只是将value设置为100),但我不想在按钮上显示“ 100”显示“ 200”。
In this case, is there a way to do it ? 在这种情况下,有办法吗? what if I don't use "button" instead? 如果我不使用“按钮”怎么办?
Thanks very much! 非常感谢!
Depending on what you're actually trying to accomplish, one way would be to use a hidden field instead of relying on the button's value: 根据您实际要完成的工作,一种方法是使用隐藏字段而不是依赖按钮的值:
<!-- Instead of -->
<form>
<input type="submit" name="buttonName" value="200">
</form>
<!-- Do this -->
<form>
<input type="hidden" name="buttonName" value="100">
<input type="submit" value="200">
</form>
Or you can use a button
instead of input
, and it can have a different text and value: 或者,您可以使用button
代替input
,它可以具有不同的文本和值:
<form>
<button type="submit" name="buttonName" value="100">200</button>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.