Jump to content

Making A Form That Adds To Links

Go to solution Solved by elpiop,
<script>
function setLink() {
    document.getElementById("link").href = "http://example.com/" + document.getElementById("my_input").value
}
</script>

<form>
<input type="text" id="my_input" oninput="setLink()">
<a href="http://example.com/" id="link"> Click me </a>
</form>

 

This is very hard to explain. How do I make a form that adds to a link?

For example: When I enter "test" into the form, it takes you to www.example.com/item/test

Another example: When I enter "hello" it takes me to www.dictionary.com/words?=hello

 

Is this possible? And if it is how do I do it? I want to integrate this into my site.

Link to comment
Share on other sites

Link to post
Share on other sites

<script>
function setLink() {
    document.getElementById("link").href = "http://example.com/" + document.getElementById("my_input").value
}
</script>

<form>
<input type="text" id="my_input" oninput="setLink()">
<a href="http://example.com/" id="link"> Click me </a>
</form>

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/9/2019 at 2:40 PM, elpiop said:

<script>
function setLink() {
    document.getElementById("link").href = "http://example.com/" + document.getElementById("my_input").value
}
</script>

<form>
<input type="text" id="my_input" oninput="setLink()">
<a href="http://example.com/" id="link"> Click me </a>
</form>

 

Thanks!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×