<select name="gamelist" id="gamelist">
<option value="1">Backgammon</option>
<option value="2">Chess</option>
</select>
<input type="submit" name="submit" id="submit" value="Submit" />
i want to grab the selected value and place in in a var any idea? thanks
我想抓住所选的值并在var中放入任何想法?谢谢
3 个解决方案
#1
2
Depends on your form tag.
取决于您的表单标签。
<form method="post">
Will pass the value to $_POST['gamelist']
将值传递给$ _POST ['gamelist']
While
<form method="get">
Will pass the value to $_GET['gamelist']
将值传递给$ _GET ['gamelist']
Ofcourse, only after hitting the submit button. As morgar stated, this is pretty basic form procession. I doubt you've used google or followed a tutorial, this is almost one of the first things one learn when working with forms and PHP. We arent here to give you full solutions, take this as an example and create the full page yourself:
当然,只有在点击提交按钮后。正如morgar所说,这是非常基本的形式游行。我怀疑你是否使用谷歌或遵循教程,这几乎是使用表单和PHP时学到的第一件事。我们不是为您提供完整的解决方案,以此为例,自己创建整个页面:
if($_SERVER['REQUEST_METHOD'] == "Y") {
$choice = $_Y['gamelist'];
// other stuff you want to do with the gamelist value
} else {
echo '<form method="Y" action="file.php">';
// the rest of your form
echo '</form>';
}
Replace Y with either GET or POST.
用GET或POST替换Y.
#2
1
$choice = $_REQUEST['gamelist']; //works with get or post
#3
0
$choice = $_POST['gamelist']
if it is a POST, or $_GET if not.
如果是POST,或者如果不是$ _GET。
#1
2
Depends on your form tag.
取决于您的表单标签。
<form method="post">
Will pass the value to $_POST['gamelist']
将值传递给$ _POST ['gamelist']
While
<form method="get">
Will pass the value to $_GET['gamelist']
将值传递给$ _GET ['gamelist']
Ofcourse, only after hitting the submit button. As morgar stated, this is pretty basic form procession. I doubt you've used google or followed a tutorial, this is almost one of the first things one learn when working with forms and PHP. We arent here to give you full solutions, take this as an example and create the full page yourself:
当然,只有在点击提交按钮后。正如morgar所说,这是非常基本的形式游行。我怀疑你是否使用谷歌或遵循教程,这几乎是使用表单和PHP时学到的第一件事。我们不是为您提供完整的解决方案,以此为例,自己创建整个页面:
if($_SERVER['REQUEST_METHOD'] == "Y") {
$choice = $_Y['gamelist'];
// other stuff you want to do with the gamelist value
} else {
echo '<form method="Y" action="file.php">';
// the rest of your form
echo '</form>';
}
Replace Y with either GET or POST.
用GET或POST替换Y.
#2
1
$choice = $_REQUEST['gamelist']; //works with get or post
#3
0
$choice = $_POST['gamelist']
if it is a POST, or $_GET if not.
如果是POST,或者如果不是$ _GET。