In this article I will explain with an example, how to pass (send) Parameters using HyperLink in HTML.
The HTML HyperLink will be assigned an OnClick event handler and when clicked, the value of the TextBox will be set in the HREF attribute of the HTML HyperLink using JavaScript.
When the HTML Anchor Link is clicked, the TextBox value will be passed to the other Page as QueryString parameter using JavaScript.
HTML Markup
The HTML Markup consists of an HTML TextBox and an HTML Anchor Link.
<input type="text" id="txtName"/>
<a href = "javascript:;">Send</a>
Passing (Sending) Parameters using HyperLink in HTML
The HTML Anchor Link is assigned an OnClick event handler and when clicked, the value of the TextBox is set in the HREF attribute of the HTML Anchor Link using JavaScript.
When the HTML Anchor Link is clicked, the TextBox value is passed to the other Page as QueryString parameter.
<a href = "javascript:;" onclick = "this.href='Page2.htm?name=' + document.getElementById('txtName').value">Send</a>
Screenshot
Browser Compatibility
The above code has been tested in the following browsers.
* All browser logos displayed above are property of their respective owners.
Downloads