javascript - How to open different URLs by different buttons? -


this html , javascript code

<input type="text" id="text" />  <input type="button" id="btn" value="submit" onclick="javascript: window.open('http://example.com/' + document.getelementbyid('text').value);" /> 

if input anytext in form box , click on submit button, open: http://example.com/anytext.

i want add 3 buttons named page1 page2 , page3 under form. if click on button page1 , click on submit button, open: http://example.com/page1/anytext

how can it?

hope works you

<input id="text" type="text" name="text"> <input type="button" name="page1" onclick="javascript:window.open('http://example.com/' + this.name + '/' + document.getelementbyid('text').value)" value="page1"> <input type="button" name="page2" onclick="javascript:window.open('http://example.com/' + this.name + '/' + document.getelementbyid('text').value)" value="page2"> <input type="button" name="page3" onclick="javascript:window.open('http://example.com/' + this.name + '/' + document.getelementbyid('text').value)" value="page3"> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -