THEE NES
THEE NES

Reputation: 115

How to pass parameter in javascript's url?

I have a javascript function to open the new window when we click the link but i want to pass the value "id" to another page. How can I add the value to url> Following is the code...

 <SCRIPT language="JavaScript1.2">
    function openoldgurantorwindow()
      {
     window.open("enter code heregurrantor/old",
    "mywindow","location=1,status=1,scrollbars=1,width=700,height=700");
    }
    </SCRIPT>
    <a href="javascript: openoldgurantorwindow()">Click to view old Guarantors</a> 

Thank you in advance.

Upvotes: 0

Views: 65

Answers (1)

Lovepreet Singh
Lovepreet Singh

Reputation: 4860

You can pass id or any other parameter as query params like shown below:

function openoldgurantorwindow(id) {
    window.open("http://example.com?id=" + id,
            "mywindow", "location=1,status=1,scrollbars=1,width=700,height=700");
}

And can be retrieved at next page in PHP code in $_GET variable.

Upvotes: 1

Related Questions