URL份额传递参数
问题描述:
答
这是我将如何处理这一简单的逻辑:
var sel = document.querySelector("#ddlViewBy");
var input = document.querySelector("input#location");
var button = document.querySelector("button");
var param1 = '';
var param2 = '';
button.addEventListener("click", function(evt){
param1 = sel.options[sel.selectedIndex].value;
param2 = input.value;
//Just to check the value
//alert(param1 + ", " + param2);
});
//Then reconstruct your URL bar with the params above
/**
* orig_url = window.location.href;
* window.location.href = orig_url + '?city=' + param1 + '&zip=' + param2
*
**/
<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" selected="selected">test2</option>
<option value="3">test3</option>
</select>
<input type="text" id="location" placeholder="Location" />
<button type="button">Submit</button>
我希望这有助于。
什么是执行上面的函数的代码? – Sheedo
它是一个名为ezfc form calculator的第三方插件。它使用这些参数将字段值转发到下一页,我希望第二个用户使用相同的参数浏览同一页面。 –
某些格式问题+次要语义 – meowgoesthedog