我有2个下拉菜单(projectnumnmer和projectnaam),它们搜索表“ projecten”并显示可以选择的添加数据,效果很好!,尽管我希望这些下拉菜单可以找到彼此的匹配项,并且将相应的(匹配)数据填写到另一个字段中,反之亦然。
希望有人能帮助我,帮助将不胜感激。 :-)
这是我现在拥有的代码:
<!-- ***************** Projectnummer ***************** -->
<tr valign="top">
<td><?php echo "$language019"; ?></td>
<td>
<!-- ***************** Projectnummer selecteren uit database ***************** -->
<?php $result = mysqli_query($mysqli, "SELECT * FROM projecten ORDER BY pnummer ASC"); // using mysqli_query instead ?>
<img src="images/projectnummer.png"> <select id="projectnummerselect" name="projectnummer2" onchange="myFunction2()">
<option selected><?php echo "$language176"; ?>.</option>
<?php
while($res = mysqli_fetch_array($result)) {
echo "<option value='".$res['pnummer']."'>".$res['pnummer']."</option>";
}
?>
</select>
<br />
<script>
function myFunction2() {
var x = document.getElementById("projectnummerselect").value;
document.getElementById("projectnummer").value = "" + x;
}
</script>
<input type="text" id="projectnummer" size="4" maxlength="6" name="projectnummer" onfocus="this.value='19'" value="<?php echo $_COOKIE["cprojectnummer"]; ?>">
<!-- ***************** /Projectnummer selecteren uit database ***************** -->
</td>
</tr>
<!-- ***************** /Projectnummer ***************** -->
<!-- ***************** Projectnaam ***************** -->
<tr valign="top">
<td><?php echo "$language020"; ?></td>
<td>
<!-- ***************** Projectnaam selecteren uit database ***************** -->
<?php $result = mysqli_query($mysqli, "SELECT * FROM projecten ORDER BY pnaam ASC"); // using mysqli_query instead ?>
<img src="images/projectnaam.png"> <select id="projectnaamselect" name="projectnaam2" onchange="myFunction3()">
<option selected><?php echo "$language177"; ?>.</option>
<?php
while($res = mysqli_fetch_array($result)) {
echo "<option value='".$res['pnaam']."'>".$res['pnaam']."</option>";
}
?>
</select>
<br />
<script>
function myFunction3() {
var x = document.getElementById("projectnaamselect").value;
document.getElementById("projectnaam").value = "" + x;
}
</script>
<input type="text" id="projectnaam" size="40" name="projectnaam" value="<?php echo $_COOKIE["cprojectnaam"]; ?>">
<!-- ***************** /Projectnaam selecteren uit database ***************** -->
</td>
</tr>
<!-- ***************** /Projectnaam ***************** -->