Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 基于链接到DB的combox在标签中显示值_Javascript_Php_Html - Fatal编程技术网

Javascript 基于链接到DB的combox在标签中显示值

Javascript 基于链接到DB的combox在标签中显示值,javascript,php,html,Javascript,Php,Html,下面是我基于combox将值传递到标签的尝试。假设我从combox中选择A,标签必须更改为1。如果我选择B,标签将更改为2 以下是我的尝试: kota.php: com_txt.php javascript发生在这里 要将标签值更改为选定选项的索引 函数myfunselect{ document.getElementById'some'。innerText=select.selectedIndex; } 0 2. 3. 不要使用mysql函数:要传递索引或值吗?让我猜猜,若你们在select

下面是我基于combox将值传递到标签的尝试。假设我从combox中选择A,标签必须更改为1。如果我选择B,标签将更改为2

以下是我的尝试:

kota.php:

com_txt.php


javascript发生在这里

要将标签值更改为选定选项的索引

函数myfunselect{ document.getElementById'some'。innerText=select.selectedIndex; } 0 2. 3.
不要使用mysql函数:要传递索引或值吗?让我猜猜,若你们在select php中选择了option,就会用从数据库中获取的结果改变标签的值,我想你们正在寻找类似AJAxDone的东西。谢谢你的帮助
$conn=mysql_connect('localhost','root','root');
$sel = mysql_select_db('test',$conn);
$alamat=$_POST['alamat'];
$query=mysql_query('select * from alamat where jalan="'.$alamat.'"');
while ($data=mysql_fetch_array($query)){
echo '<label value= "' .$data[2].'"> <b> ' .$data[2].' </b> </label>;
}

?>
<!DOCTYPE html>
<html>
   <title>Test Calculator</title>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="css.css">
   <link type="text/css" rel="stylesheet" href="style.css"/>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald">
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open Sans">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.10.2.js"></script>
   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
   <script src="jquery.min.js"></script>
   <body>
      <label> Jalan: </label>
      <select name="alamat" id="alamat" onchange=kota(this.value)";>
         <option value=""> --Items -- </option>
         <?php $j1=mysql_query($con,'select * from alamat order by id ASC');
            while ($jalan=mysqli_fetch_row ($j1)){
            echo '<option value="'.$jalan[1].'</option>';
            }
            ?>
      </select>
      </br>
      <label> </br></br> kota:</label> <label name="kota" id="kota"> <b> label</b><label>
   </body>
</html>