如何从更改下拉框php和html中获取选定值 管理 校名 - $(函数(){ $('#selectnumber')。更改(函数(){ 警报('.val()='+$('#selectnumber').val()+'和html()='+$('#selectnumber选项:选定').html()+'和.text()='+$('#selectnumber选项:选定').text()); }) }); 一 二 三 四

如何从更改下拉框php和html中获取选定值 管理 校名 - $(函数(){ $('#selectnumber')。更改(函数(){ 警报('.val()='+$('#selectnumber').val()+'和html()='+$('#selectnumber选项:选定').html()+'和.text()='+$('#selectnumber选项:选定').text()); }) }); 一 二 三 四,php,mysql,html-select,Php,Mysql,Html Select,谢谢……:) 请包括var\u转储($\u POST)在PHP脚本的开头,重复相同的过程,并向我们显示输出。这是一个拼写错误,其中school='sn'您忘记了$符号。投票结束。您正在查找sn字符串文字。这个问题本身并不是一个“答案”。sn是它在数据库@Fred ii-@Julie Pelletier I中的名称,它在问题的开头添加了var_dump()script@Nick1615:我特别要求一个var\u转储($\u POST)查看实际发送的内容与您的期望不符,而不仅仅是电子邮件。 <


谢谢……:)

请包括
var\u转储($\u POST)
在PHP脚本的开头,重复相同的过程,并向我们显示输出。这是一个拼写错误,其中school='sn'您忘记了
$
符号。投票结束。您正在查找
sn
字符串文字。这个问题本身并不是一个“答案”。sn是它在数据库@Fred ii-@Julie Pelletier I中的名称,它在问题的开头添加了var_dump()script@Nick1615:我特别要求一个
var\u转储($\u POST)
查看实际发送的内容与您的期望不符,而不仅仅是电子邮件。
<?php
session_start();
include_once "Dbconnect.php";
if(isset($_POST['btn_up'])){
  $email = $_POST['sn'];
  if($email == ''){
    echo 'there was an error';
  }else{
    echo $email;
    echo "something happened";
  }
}
var_dump($email);
?>
<!DOCTYPE html>
<html>
<head>
<title> Admin </title>
</head>
<body>

  <form method='post'>
    <label for="select">School name</label>
    <select name="sn">
        <option value="-" selected data-default>-</option>
        <?php
            $query = mysql_query("SELECT * FROM users WHERE school = 'sn'");
            while($rowtwo = mysql_fetch_array($query)){
                ?>
                <option value="<?php echo $rowtwo['email']; ?>"><?php echo $rowtwo['email']; ?></option>
                <?php
            }
        ?>
    </select>

<button type="submit" name='btn_up'>up</button>
</form>

</body>
</html>
 <script src="jquery-3.1.0.js"></script>
    <script>
        $(function () {
            $('#selectnumber').change(function(){
                alert('.val() = ' + $('#selectnumber').val() + '  AND  html() = ' + $('#selectnumber option:selected').html() + '  AND .text() = ' + $('#selectnumber option:selected').text());
            })
        });
    </script>
 <select id="selectnumber">
            <option value="1">one</option>
            <option value="2">two</option>
            <option value="3">three</option>
            <option value="4">four</option>
        </select>