I have the following code:
<script type="text/javascript"> function changeText2(){ var userInput = document.getElementById('userInput').value; var lnk = document.getElementById('lnk'); lnk.href = "www.google.com/search/" + userInput; lnk.innerHTML = lnk.href; } </script> Here is a link : <a href="" id=lnk>nothing here yet</a> <br> <input type='text' id='userInput' value=' ' /> <input type='button' onclick='changeText2()' value='Change Link'/> So, this basically does the following:
User enters a word in the text box, and that word is appended at the end of the link given (www.google.com/search/). And the link is displayed above on the page.
But instead of displaying the link on the page, I want it to open that page when the button is clicked. How can I do that?