Pass value from one page to another’s input

Asked

Viewed 48 times

1

i have an html page where the user type in the email and I perform the check. If that email is not in the database, it is a new user and therefore redirect to the registration page.

On the registration page I want the email field to come already with the email typed on the previous page. How do I?

page 1

 <label id=id_email name="email"> </label>

page 2

   <label id=id_email name="email"> </label>

    $( document ).ready(function() {
           $("#id_email").val("[email protected]");
 });
  • Send by session or querystring.

  • The idea is to send by session anyway, but I don’t know how to do, I’m learning

  • What language are you using?

  • Python using Django

  • I don’t even know a Python line. Sorry!

2 answers

0

You could try it this way.

<input type="hidden" name="volposition" value="{{ request.REQUEST.email }}">

Taking into account that you do in the action the post to send the other page.

0


You can use sessionStorage, this way the browser will save a sessão with your data and you can recover on any page.

Page 1

<input type="text" id="email">
<script>
    let valor = document.getElementById('email').value
    sessionStorage.setItem('email', valor)
</script>

Page 2

<input type="text" id="RecuperaEmail">

<script>
    document.getElementById('RecuperaEmail').value = sessionStorage.email
</script>

Or you can do it with jQuery

Page 1

<input type="text" id="email">
<script>
    var valor = $('#email').val()
    sessionStorage.setItem('email', valor)
</script>

Page 2

<input type="text" id="RecuperaEmail">

<script>
    $('#RecuperaEmail').val(sessionStorage.email)
</script>
  • Thanks Rafael, I managed to solve!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.