我有一个包含许多字段的html表单:
<form action="" method="get">
...
<input type="checkbox" name="price" id="price-1000" value="1000">
<input type="checkbox" name="price" id="price-2000" value="2000">
<input type="checkbox" name="price" id="price-3000" value="3000">
...
<input type="submit" value="send">
</form>在检查并发送时,我有以下查询字符串:?price=1000&price=2000
如何在浏览器URL中设置为?price=1000,2000
我想我需要一个通过htaccess的重写规则?还是有别的办法?
发布于 2019-04-09 14:23:33
使用Jquery可以做到这一点。
index.php
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<form action="redex.php" method="get">
<input type="checkbox" id="price-1000" value="1000" class="ckbox">
<input type="checkbox" id="price-2000" value="2000" class="ckbox">
<input type="checkbox" id="price-3000" value="3000" class="ckbox">
<input type="hidden" name="price" id="price-1000" value="1000" class="ckvalues">
<input type="submit" value="send">
</form>
<script type="text/javascript">
$(document).ready(function() {
var favorite = [];
$('.ckbox').change(function() {
$.each($("input[type='checkbox']:checked"), function(){
favorite.push($(this).val());
});
var str1 = favorite.toString()
$('.ckvalues').val(str1)
favorite.length = 0;
});
});
</script>redex.php
<?php
echo $_GET['price'];
?>希望这对你有帮助。
https://stackoverflow.com/questions/55585870
复制相似问题