Question: as the above stated, I wish to make once user click the hyperlink and it should copy into a variable in PHP. Is it possible to do it?

This is what I have tried but nothing seems to come out?

**Code:**

```
    <script type="text/javascript">
    function getdl(){
        var dlink = (document.getElementById('getdllink').getAttribute('onclick'))
         <? $url ?> = var dlink
    }
    </script>

<a id="getdllink" onclick="getdl()" href="#"><strong>Master Prospectus</strong></a></font>
            <? echo $url; ?>

```

I did something wrong? Please help. Thanks!

Answer: 
It's not possible what you are doing ... But it can be done by ajax.

What php does is:

![enter image description here](https://i.stack.imgur.com/bEUKt.png)

So you need to make an ajax call and assign it to the php variable.

I would suggest you use jquery. It's very simple and effective. 

You can send the data by 

jquery:

```
$("id or class of link").live("click",function(){
var val = $("#getdllink").val();

$.ajax({
  type: "POST",
  url: "some.php",
  data: { value :  val    }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );
});
 return false; // Prevent browser from visiting link
})

```

and in some.php 

```
$var = $_POST['value'];

```

**the above method won't need to refresh the page** 

to send this by url check the @PLB answer, it's good
Here is how to do it without AJAX or PHP...

```
<script type="text/javascript">
function getdl(){
    var dlink = (document.getElementById('getdllink').getAttribute('href'))
    document.getElementById('dest').innerHTML = dlink
    return false
}
</script>

<a id="getdllink" onclick="return (getdl())" href="http://www.google.com"><strong>Master Prospectus</strong></a><br />

<span id="dest"></span>

```