如何通过<a href="" tag=""

时间:2015-07-10 20:33:42

标签: javascript html5 jsp

="" In the above JSP i am trying to pass the text box value through href tag. I came across the above syntax in stackoverflow. But it does not seem to be working. Need help.

HTML

<input id="orderedItems" type="text" name="orderedItems" value="hiii" /> 
<a href='products.jsp?id=1&loginid=${userName}&orderim='+ document.getElementById('orderedItems').value;>

1 个答案:

答案 0 :(得分:0)

您应该在输入的onchange事件中更改href属性。

Example

var link = document.getElementById("link"),
    txt = document.getElementById("txt"),
    baseUrl = link.href;

txt.onchange = function() {
    link.href = baseUrl + "?param=" + this.value;
};