我正在从数据库中获取值并将它们显示在组合框中,现在我想在文本字段中显示选定的组合框值我试图解决它但我无法帮助我.....这是我的代码
<form name="form" method="POST" action="time.php" enctype="multipart/form- data">
<table align="center">
<p>
<tr><td>
<label>Depurture</label></td>
<td>
<script>
function CBtoTB()
{
document.getElementById("text").value=document.getElementById("ComboBox").value
}
</script>
<select>
<option id="ComboBox" onchange="CBtoTB()">Select City</option>
<?php
include ('Database/db.php');
$result=mysql_query("SELECT `ctod` FROM `dewoocandd`") or die(mysql_error());
if($result)
{
while($row=mysql_fetch_array($result))
{
$cname=$row['ctod'];
echo "<option value=\"$cname\" ";
echo'SELECTED';
echo "> ";
echo $row['ctod'];
echo '</option>';
}
}
?>
</select></td></tr></td>
</p>
<p>
<tr><td> <label>Time:</label></td>
<td><input type="text" name="pname" id="text" value="" required></td></tr>
`enter code here` </p>
<tr><td> </td><td align="right"> <input type="submit" name="button" id="button" value="Submit"></td></tr>
</table>