本文介绍了用户单击组合框后(具有一些规则),重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是javascript的新手,需要在用户单击组合框的选项后重新加载当前页面,但是我有一些规则.
I'm new in javascript and need I to reload the current page after user clicks on the options of combobox, but I have some rules.
两个组合框:
<select onChange="Refresh(this.value)" name="comboA">
<option value="0">0</option>
<option value="1">1</option>
</select>
<select onChange="Refresh2(this.value)" name="comboB">
<option value="2">2</option>
<option value="3">3</option>
</select>
规则:
- 用户在第一个组合框中单击"0",然后重新加载到 comboA = 0 .
- 用户在第一个组合框中单击"1",将"0"替换为"1",然后重新加载到 comboA = 1
- 用户在第二个组合框中单击"2",并连接并重新加载到 comboA = 1& comboB = 2
- 用户单击第二个组合框中的"3",将"2"替换为"3",然后重新加载到 comboA = 1 comboB = 3
- user clicks on "0" in the first combobox, reload to comboA=0.
- user clicks on "1" in the first combobox, replaces "0" to "1" and reload to comboA=1
- user clicks on "2" in the second combobox, concatenate and reload to comboA=1 & comboB=2
- user clicks on "3" in the second combobox, replaces "2" to "3" and reload to comboA=1 comboB=3
上述步骤需要按顺序进行.
The steps above need to be done in sequence.
函数"Refresh"
和"Refresh2"
应该如何?
谢谢.
推荐答案
您可以按照以下步骤进行操作:
you can do it like following:
var url = "http://www.mypage.com?"
$("select[name=comboA]").on("change",function(){
window.location.href = url + $(this).attr("name") + "=" + $(this).val();
});
然后第二次选择
var url2 = "http://www.mypage.com?comboA=1&"
$("select[name=comboB]").on("change",function(){
window.location.href = url2 + $(this).attr("name") + "=" + $(this).val();
});
这篇关于用户单击组合框后(具有一些规则),重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!