此下拉列表值和按钮。当你点击按钮的第一个值将被移除,第二个值将在下拉列表在数据库中获取行
document.getElementById("demo").innerHTML = txt;
<p id="demo"></p>
其工作正常进行呼应,但我想在我的数据库depened什么是id演示的行。任何帮助将不胜感激谢谢
<!DOCTYPE html>
<html>
<body>
<form>
<?php
require('connection.php');
$positions=mysql_query("SELECT * FROM tbPositions")
or die("There are no records to display ... \n" .
mysql_error());
?>
<td><SELECT NAME="position" id="position" onclick="getPosition(this.value)">
<OPTION VALUE="select">select
<?php
while ($row=mysql_fetch_array($positions)){
echo "<OPTION VALUE=$row[position_name]>$row[position_name]";
}
?>
</SELECT></td>
</form>
<br>
<button onclick="myFunction()">Remove option with index "1"</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("position");
x.options.remove(0);
var x = document.getElementById("position").options.item(0).text;
document.getElementById("demo").innerHTML = x;
}
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
你问,如果你可以从ID数据库中获得值,这是回显? – Ravi
是的。它是可行的吗? –
是的,这是可能的 – Ravi