ex501 ex501 - 4 years ago 108
Javascript Question

Redirect based on user input

I have 20 different pages. Let's say that IDs of the pages are for example:

and so on...

I need to create an input field where the user can enter numbers, and if he inputs number 16 for example, it will redirect him to

I believe that this is possible with JavaScript. Has anyone got any advice?

Answer Source

window.onload = function() {
  document.getElementById('btn').onclick = function()
    window.location.href = "http://www.yourdomain.com/page"+document.getElementById("url").value
<input id="url" value="">
<button id="btn">Go!</button>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download