Upload a page after filling in a textfield using jQuery

0

I'm doing a Jokenpo game, and I need a username to put on the Score. In the case I created a home page with a textfield for the user to enter his name. Just after typing your name, you should open the other page where the game is with the options.

<div class="container">
    <input type="text" id="nameJogador" placeholder="Nome do Jogador">

</div> 


$(document).ready(function(){

$("#nameJogador").focusout(function(){
    var nomeJogador = $("#nameJogador").val();
    //$("input#nameJogador").load('index_game');
    alert(nomeJogador);
    });


});
    
asked by anonymous 30.10.2017 / 15:49

1 answer

1

If I understand correctly, you can use localStorage to store the name you typed on the previous page, eg:

<div class="container">
    <input type="text" id="nameJogador" placeholder="Nome do Jogador">
</div> 


$("#nameJogador").focusout(function(){
    var nomeJogador = $(this).val()
    localStorage.setItem('jogador', nomeJogador)

    window.location.href = 'outraPAgina' 
});

Once you've done that, you've already gone to the other page and have the player name stored in localStorage , now you just have to recover (when necessary).

$('#score').text('O nome do jogador é: ' + localStorage.jogador)
    
30.10.2017 / 15:57