Automated HTML Link based in DIV ID value - NO JQUERY only Javascript
===

please help me in the following issue

what i want is that in my webpage, have a button that states "Generate Link" when clicked the button should read the webpage for an specific [DIV ID="site"] and when found modify an pre-defined URL "http://wwww.example.com"+"Site"..


Here is my code that generates the link + "undefined"

<pre><code>
    <script type="text/javascript">
 
    function changeText()
    { 
      var ste = document.getElementById('userInput2').value;  
      var lnk = document.getElementById('lnk');
      lnk.href = "http://www.google.com?q=" + ste;   
      lnk.innerHTML = lnk.href; } 

    </script>
    <div id="userInput2">Google</div>
    Please enter your event country in order to generat that link.<br>
    <input type='button' onclick='changeText()' value='Generate Link'/> <br>
    <a href="" id=lnk></a> 
    </pre></code>

Thank You!