我通过谷歌找到了一些我可以使用的代码,应该更正它以适合我,但是当我从下拉菜单中选择一些东西时,什么也没有发生。不知道我做错了什么。
<select name="h1" id="h1">
<?php
echo "<option value=".$rowlift['H1'].">".$rowlift['H1']."</option>";
$pris = mysql_query("SELECT * FROM priser ORDER BY id ASC");
while($rowP = mysql_fetch_assoc($pris))
echo "<option value='".$rowP['pris'].",".$rowP['id']."'>".$rowP['hojde']. "</option>";
?>
</select>
<?php
if($rowlift['p1'] != '')
echo "<input type='text' id='pris1' name='p1' value='".$rowlift['p1']."'>";
else
echo "<input type='text' id='pris1' name='p1'>"
?>
<script type="text/javascript">
var mytextbox = document.getElementById('pris1');
var mydropdown = document.getElementById('h1');
var mySplitResult = mydropdown.split(",");
mydropdown.onchange = function(){
mytextbox.value = mySplitResult[0];
}
</script>
我希望这是您正在寻找的想法..当我选择某些东西时,什么也没有发生。
<select name="h1" id="h1">
<option value=""></option>
<option value="80,1">1000m</option>
<option value="90,2">1200m</option>
<option value="100,3">1500m</option>
<option value="110,4">2000m</option>
<option value="120,5">2250m</option>
<option value="130,6">2500m</option>
<option value="140,7">3000m</option>
<option value="150,8">3500m</option>
<option value="160,9">4000m</option>
<option value="160,10">Elev man.</option>
<option value="160,11">Elev auto</option>
<option value="0,12">HM</option>
<option value="2000,13">Tandem pass u/video</option>
<option value="2300,14">Tandem håndhold video</option>
<option value="2600,15">Tandem pass m/video</option>
<option value="0,16">Tandem master</option>
<option value="-100,17">Tandem video</option>
</select>
<td>
<input type="text" id="pris1" name="p1"> <script type="text/javascript">
var dropdownId = document.getElementById("h1");
var mytextbox = document.getElementById('pris1');
var mySplitResult = strUser .split(",");
dropdownId.onchange = function(){
mytextbox.value = mySplitResult[1] //to (not) appened
//mytextbox.innerHTML = this.value;
}
</script>
</td>