how could I insert this

0

I have this script:

$(document).on('click', '.tipo-sangre', function(event){

  var tipo = $(this).data("sangre");
  $(tipo).appendTo("#tipo_sangre");

});

What I want is to give clik me pass the value of the var to a hidden type input to be able to make the request and save it in the database but I do not know how to send it to the input by the way the inpout is the id= #tipo_sangre as I could do so that the var is saved in it and be able to send it with request

    
asked by Jon Solis 17.12.2018 в 23:27
source

1 answer

0

I understand that what you want to do is to collect the value of the variable "type" and put it in the hidden field, no?

$(document).on('click', '.tipo-sangre', function(event){

  var tipo = $(this).data("sangre");
  //esta última parte la hacías al reves.
  //primero asignas a que elemento de html haces referencia (con el selector de id, en tu caso, y luego con el metodo "val" le asignas el valor que quieres (la variable tipo, en tu caso)
  $("#tipo_sangre").val(tipo);

});
    
answered by 17.12.2018 / 23:41
source