简体   繁体   English

HTML表单:如何在不显示表单的情况下提交值?

[英]HTML form: how to submit a value without showing it in the form?

I have an HTML form that sends a food dish. 我有一个发送美食的HTML表单。 For example, 例如,

placeorder.com/order.php?id=STEAK

I want to add another value and send 我想添加另一个值并发送

placeorder.com/order.php?category=MEAT&id=STEAK

But, I don't want the user to have to select meat anywhere, since this has been already decided. 但是,我不希望用户必须在任何地方选择meat ,因为这已经决定了。

I tried to tinker with the form target and include it from there, but it didn't work. 我试图修改表单目标并从那里包括它,但是它没有用。

Is there some "hidden text box" to write the category to so that it gets posted, or is there another way to do it? 是否有一些“隐藏的文本框”可将类别写入该类别以便发布,还是有另一种方式呢?

Thanks in advance! 提前致谢!

First, I just thought I'd mention that it's funny how the questions is phrased since you pretty much answered your own question: 首先,我只是想提一提,问题的措辞很有趣,因为您几乎回答了自己的问题:

Is there some "hidden text box" 是否有一些“隐藏的文本框”

Anyway, yes: 无论如何,是的:

You can use type='hidden' 您可以使用type='hidden'

I assume that you are already using a GET form so I will just include the input part: 我假设您已经在使用GET表单,所以我只包括输入部分:

<input name='category' type='hidden' value='MEAT'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM