其他分享
首页 > 其他分享> > jquery---通过输入框筛选,并通过URL参数获取将所选内容填入input框中

jquery---通过输入框筛选,并通过URL参数获取将所选内容填入input框中

作者:互联网

<div class="row">
<div class="col-sm-7">
<div class="input-group mb-3">
{% if filters %}
{% for f in filters %}
{% if "date" in f.name %}
<input type="text" name={{ f.name }} class="form-control pick-date"
placeholder="&#xf073;&nbsp {{ f.placeholder }}" autocomplete="off">
{% else %}
<input type="text" name={{ f.name }} class="form-control"
placeholder={{ f.placeholder }} autocomplete="off">
{% endif %}
{% endfor %}
<input type="hidden" name="source" value={{ source }}>
{% if 'hidden' in request.GET %}
<input type="hidden" name="hidden" value="1">
{% endif %}
<button class="btn btn-primary" type="submit" id="chaxun">查 询</button>
{% endif %}
</div>
</div>
</div>

<script>
$('.pick-date').datepicker({
format: "yyyy-mm-dd",
maxViewMode: 1,
language: "zh-CN",
defaultDate : new Date()
});

$("input:text", document.forms[0]).each(function(){
$(this).val(getUrlParam(this.name))
});

function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null)
return decodeURI(r[2]);
return null; //返回参数值
}

</script>

标签:jquery,name,URL,---,filters,endif,var,null,placeholder
来源: https://www.cnblogs.com/chilalaa/p/15793162.html