Reputation: 8346
I have a textbox with id main_category_lan1 as below.
<input type="text" name="main_category_lan1" id="main_category_lan1" Value="Hello">
And I have a link in the same page as below.
<a href="javascript: void(0)" onclick="popup('http://translate.google.com/#en/ta/'+document.getElementById('main_category_lan1').value"> Translator </a>
I want to append the textbox value to the "Onclick link" while clicking the link...
Expected output onclick is ,
<a href="javascript: void(0)" onclick="popup('http://translate.google.com/#en/ta/Hello').value"> Translator </a>
Upvotes: 0
Views: 2118
Reputation: 4564
You forgot the closing parenthesis in your onclick attribute. Also, did you mean to use window.open() instead of popup()? This works:
<a href="javascript: void(0)" onclick="window.open('http://translate.google.com/#en/ta/'+document.getElementById('main_category_lan1').value)"> Translator </a>
Upvotes: 1
Reputation: 11320
Try
function openLink() {
window.open('http://translate.google.com/#en/ta/' +
document.getElementById('main_category_lan1').value);
}
<a href="javascript: void(0)" onclick="openLink()">Translator</a>
Upvotes: 0