select 的onchange事件发生时提交请求的方式

 

第一种:结合form表单

<span style="font-size:18px;"><form action="xxxx.action" method="post">
姓名:<select name="username" onChange="javascript:this.form.submit();">
    <option>请选择</option>
    <option value="1">1</option>
    <option value="2">2</option>
    </select>
</form></span>
og.csdn.net/alexaxinzhang/article/details/41656727

第二种:结合javascript的使用,不要form表单

<span style="font-size:18px;"><select name="username" onChange="goPage(this.value)">
    <option value="">请选择</option>
    <option value="1">1</option>
    <option value="2">2</option>
</select></span>
<span style="font-size:18px;"><script type="text/javascript">
function goPage(name){
    window.location.href = "xxxx.action?username="+name;
}    
</script></span>

https://blog.csdn.net/alexaxinzhang/article/details/41656727

posted @ 2019-09-28 14:57  wonderfulviews  阅读(2684)  评论(0编辑  收藏  举报