如果选择了一个选项,我将如何通过$ _GET设置filter_branch = true和filter_branch_val = sony?
<select name="filter_brand">
<option>Sony</option>
<option>LG</option>
</select>
所以我有类似http://mypage.com/index.php?filter_branch=true&filter_branch_val=sony
的东西用于sql查询过滤器。
答案 0 :(得分:0)
你可以使用jQuery。我测试了它,它正在工作。
添加:
<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head>
HTML
<select id="myselect" name="filter_brand" onchange="javascript:goToURL()">
<option>No selection *</option>
<option>Sony</option>
<option>LG</option>
</select>
<强> SCRIPT 强>
<script>
function goToURL(url){
var option = $( "#myselect option:selected" ).text();
var yoururl = "http://www.example.com/";
var url = yoururl+ "?page="+ option;
window.location.replace(url);
}
</script>
答案 1 :(得分:0)
如果java脚本功能对你有用。请尝试此代码
HTML
<select name="filter_brand" onchange="sendFilter(this.value)">
<option>Sony</option>
<option>Lg</option>
<option>Samsung</option>
</select>
Javscript
<script type="text/javascript">
function sendFilter(vaa)
{
console.log(vaa);
window.location.href = 'product.php?
filter_branch_val='+vaa+'&filter_branch=true';
}
</script>