jQuery cutting words with space

4

I have a screen where the lines are loaded according to the data of the database and for this I have a PHP + jQuery and the like for the creation of the same one. What happens is that the array that sends the data comes correctly, but at the time of loading the field is only fed by the first word, if there are spaces it ignores. Below is the

Array:

[{"nome":"DIEGO LUIS VENUZKA","codigo":"5357","cracha":"6246286874","situacao":"ATIVO","ASO":"30\/04
\/18","id":"1","descricao":"PONTE ROLANTE (NR11 E NR12)","validade":"06\/05\/18"},{"nome":"DIEGO LUIS
 VENUZKA","codigo":"5357","cracha":"6246286874","situacao":"ATIVO","ASO":"30\/04\/18","id":"4","descricao"
:"EMPILHADEIRA A GAS (NR11 E NR12)","validade":"06\/05\/18"}]

Part of the code that loads the data from this array:

for(var i = 0;i<data.length;i++){
  HTML += "<tr><td><input type = 'text' size = '3' name = 'id[]' id = 'id[]' value=" + data[i].id + " readonly></td>";
  HTML += "<td><input type = 'text' size = '40' name = 'descricao[]' id = 'descricao[]' value=" + data[i].descricao + " readonly></td>";
  HTML += "<td><input type = 'text' size = '10' name = 'validade[]' id = 'validade[]' value=" + data[i].validade + " readonly></td>";
}

Result:

Any suggestions?

    
asked by anonymous 17.04.2018 / 14:52

1 answer

3

It turns out that you are not passing the value inside quotation marks, for example:

<input type="text" value=Stack Overflow Português />

<input type="text" value="Stack Overflow Português" />

Change to:

for(var i = 0;i<data.length;i++){
  HTML += '<tr><td><input type="text" size="3" name="id[]" id="id[]" value="' + data[i].id + '" readonly></td>';
  HTML += '<td><input type="text" name="descricao[]" id="descricao[]" value="' + data[i].descricao + '" readonly></td>';
  HTML += '<td><input type="text" size="10" name="validade[]" id="validade[]" value="' + data[i].validade + '" readonly></td>';
}
    
17.04.2018 / 14:59