What is the code to enter a specific url value in html and move it to that url address?

Asked 2 years ago, Updated 2 years ago, 45 views

In an html file

Specific

url

For example,

if there are spaces to be entered

Enter 890321 in the input column.

Pressing a specific button

ww.domain.com/890321

Is there a code that can be transferred to the address above like this?

I'd appreciate it if you let me know.

html5 web

2022-09-21 17:03

1 Answers

<script>
function doSomething() {
    // // alert(document.forms[0].elements['name'].value);
    var url = document.forms[0].elements['name'].value;
    window.location = url;
    return false;
}
</script>

<form onsubmit="return doSomething();" class="my-form">
    <input type="text" name="name">
    <input type="submit" value="Submit">
</form>

You must include http:// in the address. If you want to make it work well without http://, you can use JavaScript in doSomething.


2022-09-21 17:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.