'How to make a script that will generate a url by adding the input provided in form [duplicate]

I want to make a javascript that will redirect to the url that will be generated by adding the input provided in form and the main url.

For example , If the user puts 'Hello' inside the textbox Then it should redirect it to 'https://example.domain/Hello' And if he puts Bye then it should redirect it to 'https://example.domain/Bye'



Solution 1:[1]

You can simply grab the value of the textinput and append it to your baseurl

const inputBox = document.getElementById("input");
let newURL = 'https://example.domain/' + inputBox.value;

Please supply some Code when posting Questions to SO. Follow the How to guide https://stackoverflow.com/help/how-to-ask

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 grisuu