1

I'm completely new to javascript, and I'm trying to get a script to complete a link with a user input.

I.e. I have a common base url like http://www.mystuff.com/ and I would like to create a form to let the user reach a specific page if he knows the exact url. I need a basic input field where he can write a string (like h5mlf4) that will send him clicking the submit button to http://www.mystuff.com/h5mlf4.

I've found this script on this page which is pretty close to my needs. I've tried to modify it, but I don't know how to do both the actions (add the user's input and launch the link) on the same button with an all-in-one action. I don't want to create the link on the page, I simply need it to be immediately used.

I hope to have been clear, and thanks to everybody will take care of this.

Community
  • 1
  • 1
FrA
  • 13
  • 3

1 Answers1

1

Do

window.location = "http://www.google.com?q=" + userInput;

to "click" that link (i.e. go to that link) for the user.

Doc for window.location >> https://developer.mozilla.org/en-US/docs/DOM/window.location

luiges90
  • 4,493
  • 2
  • 28
  • 43