How do i pass a parameter to a link in html?

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.

Send

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.

Send

Screenshot

Click Here

Note: User and Company variables can be used to pass the current logged in user details and their company details.

Receiving Page

On the receiving page the parameters can pre-populate a form or an HTML element which resides on that page. In order to achieve this the following JavaScript functions can be used.

Place the following first function in the head of the HTML.

function getParams[] {
var idx = document.URL.indexOf['?'];
var params = new Array[];
if [idx != -1] {
var pairs = document.URL.substring[idx+1, document.URL.length].split['&'];
for [var i=0; i

Chủ Đề