我想使用Dropdown onchange函数进入html传递值,它在提交按钮中工作正常,但是我想使用Dropdown onchange,请帮忙怎么做?
<form method="post" action=" ">
<div align="center">
<select name="value">
<option value="">Show Value</option><br />
<option value="2"> 2 </option><br />
<option value="5"> 5 </option><br />
<option value="10"> 10 </option><br />
<option value="20"> 20 </option><br />
</select>
<input type="submit" name="submit" value="Submit">
</div>
</form>
答案 0 :(得分:5)
您应该将onChange
添加到<select>
元素中,如此
<form method="post" action=" ">
<div align="center">
<select name="value" onChange="this.form.submit()">
<option value="">Show Value</option><br />
<option value="2"> 2 </option><br />
<option value="5"> 5 </option><br />
<option value="10"> 10 </option><br />
<option value="20"> 20 </option><br />
</select>
<input type="submit" name="submit" value="Submit">
</div>
</form>