[英]How to send two parameters to Onchange function in select
我有以下代码
<option value="">Select State</option>
<?php
while($row=mysql_fetch_array($select))
{
echo "<option value=".$row['state_id'].">".$row['state']." </option>";
}
?>
</select>
</label>
<label style="margin-left:20px; width:200px; float:left; padding-top:6px;">
<select name="city" id="city" onChange="getArea('indexcontroller/indexmodules/findarea.php?city='+this.value)" style="width:220px;margin-left:3px;height:39px;margin-top:6px;">
<option value="">Select City/Town</option>
</select>
如何将状态中选择的值发送到 getArea()
你可以这样做:
<select name="city" id="city" onChange="getArea('indexcontroller/indexmodules/findarea.php?city='+$('#StatedropDownId').val();)" style="width:220px;margin-left:3px;height:39px;margin-top:6px;">
我会通过 id 选择元素并获取它的值
<select id="stateSelect">
<option></option>
<option></option>
<option></option>
<option></option>
...
</select>
<select id="citySelect" onchange="getArea('indexcontroller/indexmodules/findarea.php?state=' + document.getElementById('stateSelect').value + '&city='+this.value)">
<option></option>
<option></option>
<option></option>
<option></option>
...
</select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.