U
U
Urope2021-04-06 16:06:01
ASP.NET
Urope, 2021-04-06 16:06:01

How to go to another page on button click?

I have the following html code:

<div class="buttons">
<p><input type="text" name="userName" placeholder="Name:" size="18" /></p>
<p><input type="text" name="userName" placeholder="Name of the room:" size="18" /></p>
<a href="#" class="modal__trigger2">Join Room</a>
</div>


I want to go to another page by clicking on a button (a tag). How can I do this?
In addition to a simple transition, I also need to transfer the name and name of the room to a new page. This data should be displayed there.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Glebov, 2021-04-15
@GLeBaTi

1) add id for input.
2) make a call to this function on pressing a or button (example code):

function openURL()
{
    let user = document.getElementById('userName').value;
    let room = document.getElementById('roomName').value;
    var url = '/?user=' + encodeURIComponent(user) + '&room=' + encodeURIComponent(room) ;

    window.location.href = url;
}

3) And on another page you parse the URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question