Hi Guys,
I'm trying to build a very simple script that takes the value from a text box and places it within a link (as a parameter) then execute the link afterwards.
So the link would basically look like this
And the value from the text will be placed where {{insert}} is.Code:http://request.com/action.jsp?parameter={{insert}}
And a value from a text box :
So far I have got this:Code:<input type="text" name="tube" id="linkText">
But I'm not sure what bit I have wrong, can someone point me in the right direction and tell me why it doesn't (this is a learning exercise).Code:<html> <head> <script> var link = document.getElementById('linkid'), textBox = document.getElementById('textInputId'); function setLinkParam() { link.href = 'http://request.com/action.jsp?parameter=' + textBox.value; } textBox.addEventListener('change', setLinkParam); </script> </head> <body> <input type="text" id="textInputId"></input> <a href="http://event.com/action.jsp?param=" id=""linkid">Link</a> <input type="submit" value="Submit" action"setLinkParam()"> </body> </html>
Cheers!


Reply With Quote

Bookmarks