problem to publish a value in an input t = text with an ID

1

I have a question. I searched the web but, I could not find how it is done.

I'm seeing a system already created, but I want to modify some things.

I have an Ingreso.php page with a code that brings me the values of the database.

$siniestro[] = array("cod_ref"=>$row[0],"ramo"=>$row[1],"fecha"=>htmlentities($row[2]), etc, etc, etc);
$this->respuesta=$siniestro;
return  $this->respuesta;

which gives me a return response.

Well I read it with this:

$.getJSON("siniestro.php",{x:x},function(detalleFT){
  $.each(detalleFT[0], function(key,valor){ 
    $("#"+key).html(valor);
  });
});

with this I get the values of my sinister page by ID, which I want to show them in input="text", but the input text appear empty, not so if I dump them in a for example, but what interests me is to make those editable fields in the input text but with the value already loaded in the IDs.

I do not know if my explanation is very clear.

maybe I'm picking them wrong by ID, or if it would be easier to pass it to php variables, I do not know, I need help on this topic, I'm a bit stuck.

    
asked by Francisco Andrade 08.09.2016 в 02:47
source

2 answers

0

Greetings, you should use the following:

$("#"+key).val(valor);
    
answered by 08.09.2016 в 05:42
-1

The function of jquery .html() does not work for you in this case. In your case it would be something like:

//linea de codigo donde colocas tu dato
$("#"+key).attr( "atributo", valor );

This assuming that the <input> created field is already

    
answered by 08.09.2016 в 04:06