Call a url in javascript on click

javascript, jsp, url

Solution

Use `window.location`:

function remove()
{
    var name = ...;
    var age  = ...;

    window.location = 'http://something.jsp?name=' + name + '&age=' + age;
}

Problem

I have a javascript function. On-click will call this. Using `document.getElementById` I am getting certain parameters there. Using that parameters I need to build a url. ie, onclick will have to execute that url. For example, in javascript, ``` function remove() { var name=...; var age = ...; // url should be like http://something.jsp?name=name&age=age } ``` In short I need to execute `http://something.jsp?name=name&age=age` this url on click ``` <input type="button" name="button" onclick="remove();" /> ```

Original source