我有以下HTML代码
<select name="select">
<option value="Select...">Select...</option>
<optgroup label="Add teachers">
<option value="add-teacher">Add a teacher</option>
</optgroup>
<optgroup label="Design">
<option value="frontpage">Redesign <b>front</b> page</option>
<option value="ratepage">Redesign <b>rate</b> page</option>
<option value="gamepage">Redesign <b>game</b> page</option>
<option value="ratepage">Redesign <b>suggestions</b> page</option>
<option value="ratepage">Redeisgn <b>news/future-updates</b> page</option>
</optgroup>
<optgroup label="Bugs/glitches">
<option value="bugs">Report a bug/glitch</option>
<option value="bugs">Report an exploit/loophole</option>
</optgroup>
<optgroup label=""></optgroup>
</select>
<form action="send.php" method="POST">
<textarea name="suggestion" class="textarea" placeholder="How can we improve this?"></textarea>
<input type="submit" class="btn">
</form>
如何使用POST方法将选定的一个项目发送到send.php
?或者GET,我不介意。像$_POST['select'];
这样的东西,可能吗?
答案 0 :(得分:3)
您的select
需要位于form
:
<form action="send.php" method="POST">
<select name="select">
<option value="Select...">Select...</option>
<optgroup label="Add teachers">
<option value="add-teacher">Add a teacher</option>
</optgroup>
<optgroup label="Design">
<option value="frontpage">Redesign <b>front</b> page</option>
<option value="ratepage">Redesign <b>rate</b> page</option>
<option value="gamepage">Redesign <b>game</b> page</option>
<option value="ratepage">Redesign <b>suggestions</b> page</option>
<option value="ratepage">Redeisgn <b>news/future-updates</b> page</option>
</optgroup>
<optgroup label="Bugs/glitches">
<option value="bugs">Report a bug/glitch</option>
<option value="bugs">Report an exploit/loophole</option>
</optgroup>
<optgroup label=""></optgroup>
</select>
<textarea name="suggestion" class="textarea" placeholder="How can we improve this?"></textarea>
<input type="submit class="btn">
</form>