Form can not fill all at once

Asked

Viewed 28 times

-4

Can anyone save me? is a form where the user places the Pokémon id and it fills in according to the API.

only that it is auto-filling all other fields, or when mute fills only the first and no more insert the picture description here

I cannot allow the user to do one by one

HTML

<div class="form-group">
                <label for="jog1">Jogador 1</label>
              
                <input name="pok1" type="number" class="form-control" id="pok11" placeholder="Nome do seu Pokemon" >
                  <div class="button floatLeft">
                  <input class="pokNome" type="text" disabled="disabled">
                  <input class="pokBase" type="text" disabled="disabled">
                  </div>
                
                <br>

                <input name="pok1" type="number" class="form-control" id="pok12" placeholder="Nome do seu Pokemon" >
                  <div class="button floatLeft">
                  <input class="pokNome" type="text" disabled="disabled">
                  <input class="pokBase" type="text" disabled="disabled">
                  </div>

                <br>

                <input name="pok1" type="number" class="form-control" id="pok13" placeholder="Nome do seu Pokemon" >
                  <div class="button floatLeft">
                  <input class="pokNome" type="text" disabled="disabled">
                  <input class="pokBase" type="text" disabled="disabled">
                  </div>


JS

$(document).ready(function(){
  $("#pok11").focusout(function(){



    var pokemon = $("#pok11").val();
    var pokemonAPIURL = "https://pokeapi.co/api/v2/pokemon/1";


    
    $.ajax({
    url: pokemonAPIURL,
    type: 'GET',
    dataType: 'json',
    success: function(data) {
      //console.log("GetPoke by ID");
      console.log(data);

      $(".pokNome").val(data.name)
      $(".pokBase").val(data.base_experience)

    }
    });
  });
});

1 answer

-3

Problem solved with

$(document).ready(function(){
  
  $(".pokload").focusout(function() {
    carregarPokemon(this.id);
  });

Browser other questions tagged

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