By Id ">By Date 我有组合框,当我-6ren">
gpt4 book ai didi

javascript - 如何对选定的组合框进行操作

转载 作者:行者123 更新时间:2023-11-28 05:35:06 25 4
gpt4 key购买 nike

Hi, i want to use search by id and search by date

<select id="menu">
<option value="<?=site_url('web/execute_search')?>">By Id</a></option>
<option value="<?=site_url('web/execute_searchs')?>">By Date</a></option>
</select>
<input type="text" name="search" />
<input type="submit" value="Submit" />

我有组合框,当我选择按 id 搜索并提交时,它将转到 Controller ('web/execute_search') ,然后如果我选择日期并提交,则转到 Controller ('web/execute_search')。

最佳答案

试试这个代码:

<select id="menu" onchange="option()">
<option value="1" content="1">By Id</a></option>
<option value="2" content="2">By Date</a></option>
</select>

<input type="text" name="search" />
<input type="submit" value="Submit" />

然后是 JavaScript:

<script>function option(){
var x = document.getElementById("menu").value;
if (x==1){
window.location.href = "execute_search";
}
if (x==2){
window.location.href = "execute_searchs";
}}</script>

关于javascript - 如何对选定的组合框进行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39421601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com