I have written a script which should change a Link by clicking on an element. But it doesn't work. Can anyone help me out?

```
<!DOCTYPE html>
<html>
<h2 id="http://www.google.com" onclick="changeLink(google);" name="google">Google</h2 >
<h2 id="http://www.yahoo.com" onclick="changeLink(yahoo);" name="yahoo">Yahoo</h2 >
<h2 id="http://www.duckduckgo.com" onclick="changeLink(duckduckgo);" name="duckduckgo">DuckDuckGo</h2 >

<a href="http://www.example.com" target="_blank" id="link">LINK</a> //should change the href after click on google, yahoo etc.

<script>
   function changeLink(x){
       document.getElementById('link').href=document.getElementsByName(x)[0].id;
   }

</script>

</body>
</html>

```