I need check box selected values get in browser url to execute query as per selection base.
html code
<div style="width:200px; float:left">
Price
<div>
<input type="checkbox" name="price" value="0-1000" class="filters" />0-1000<br />
<input type="checkbox" name="price" value="1000-2000" class="filters" />1000-2000<br />
<input type="checkbox" name="price" value="3000-4000" class="filters" />2000-3000<br />
</div>
Colors
<div>
<input type="checkbox" name="colors" value="Red" class="filters" />RED<br />
<input type="checkbox" name="colors" value="Green" class="filters" />GREEN<br />
<input type="checkbox" name="colors" value="Blue" class="filters" />BLUE<br />
</div>
</div>
javascript
<script type="text/javascript">
$('.filters').on('change',function(){
var price = new Array();
$('input[name=price]:checked').each(function(){
price.push($(this).val());
});
var colors = new Array();
$('input[name=colors]:checked').each(function(){
colors.push($(this).val());
});
location.href = 'http://localhost/test/javascript.php?price='+price;
});
</script>
When User Click on price option or color option, URL should change like this
http://localhost/test/javascript.php?price=0-1000&price=1000-2000&colors=Red&colors=Green
If user selected only single check box then should display only one parameter in url.
Is it possible with javascript ?