Here is the code that generates the link from input when the button is clicked. How to make it so that when you click it does not generate, but immediately follow the link?

<form name="idform"> <input type="text" name="id" value="Введите id"> <input type="button" value="ок!" onclick="document.getElementById('x').innerHTML='<a href=http://ya.ru/?id='+escape(document.forms['idform'].elements['id'].value)+'>Ссылка</a>'"> </form> <p id="x"></p> 
  • 2
    Why instead of an input just do not use the tag A? - Grundy
  • It is possible and <a> in principle - Nikolay

2 answers 2

 <form name="idform"> <input type="text" name="id" value="Введите id"> <input type="button" value="ок!" onclick="location.href='http://ya.ru/?id='+escape(document.forms['idform'].elements['id'].value)"> </form> 
  • Everything worked out! - Nikolay
  • one
    you can replace value="Введите id" for placeholder="Введите id" for details htmlbook.ru/html/input/placeholder - Alexey Lemesh

Another option with a different approach:

 <form name="idform"> <input type="text" name="id" placeholder="Введите id" onchange="document.getElementById('link').href='http://ya.ru/?id='+escape(this.value)" /> <a id="link" href="http://ya.ru/">ок!</a> </form>