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();" />
JavaScript window. The syntax for this approach is: window. location = "url"; “url” represents the URL you want the user to visit.
The JavaScript to click it: document. getElementById("my-link-element"). click();
This is a type of JavaScript link - the onclick attribute defines a JavaScript action when the 'onclick' event for the link is triggered (i.e. when a user clicks the link) - and there is a URL present itself in the onclick attribute.
Use window.location
:
function remove()
{
var name = ...;
var age = ...;
window.location = 'http://something.jsp?name=' + name + '&age=' + age;
}
I use:
document.location.href = "report.html";
So, in your case:
function remove() {
var name=... ,
age = ...;
document.location.href = "something.jsp?name=" + name + "&age=" + age;
}
just call
window.location=myURL;
in your function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With