从具有选择和选项值的表单获取POST或GET值

时间:2022-07-19 12:13:00

So I have this list of option values, and I want a user to be able to select any item on the drop down list and submit it, and this will delete a record (I have a custom Python script that will do it).

所以我有这个选项值列表,我希望用户能够选择下拉列表中的任何项目并提交它,这将删除一条记录(我有一个自定义Python脚本将执行此操作)。

Anyway, how do I send, say

无论如何,我怎么发送,比方说

<form action="delete.psp" method="get">
<select>
<option value="id=1">1</option>
<option value="id=2">2</option>
</select>
</form>

I am trying to send numeric information to the script - should I switch id=1, etc to simply 1? Would this work?

我正在尝试向脚本发送数字信息 - 我应该将id = 1等转换为1吗?这会有用吗?

To be clear, I am trying to send the data as the variable id inside of get, with the value of 1, 2, etc.

为了清楚起见,我试图将数据作为变量id发送到get中,值为1,2等。

1 个解决方案

#1


3  

You just need to give your select a name so that the browser knows what to send it to the server as. (Also: you need a submit button unless you're doing it in code.)

您只需要选择一个名称,以便浏览器知道将其发送到服务器的内容。 (另外:你需要一个提交按钮,除非你在代码中这样做。)

<form action="delete.psp" method="get">
<select name="blah">
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" />
</form>

Personally I would just set value="1"

就个人而言,我只想设置value =“1”

#1


3  

You just need to give your select a name so that the browser knows what to send it to the server as. (Also: you need a submit button unless you're doing it in code.)

您只需要选择一个名称,以便浏览器知道将其发送到服务器的内容。 (另外:你需要一个提交按钮,除非你在代码中这样做。)

<form action="delete.psp" method="get">
<select name="blah">
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" />
</form>

Personally I would just set value="1"

就个人而言,我只想设置value =“1”