Select does not load the options correctly [closed]

0

Good morning Galera Dev, since yesterday I came across a somewhat bizarre situation (if I may say so).

I'm using php poo to load a select and bringing the response into a while:

while($dados = $sql->fetch_assoc()){
    $cd_cobr = $dados["cd_tipo_cobr"];
    $ds_cobr = $dados["ds_tipo_cobr"];

    echo("<option value='$cd_cobr' selected='yes'> $ds_cobr </option>");
    echo("$cd_cobr $ds_cobr");
}

I've done it that way 1 million times, but since yesterday it's loading the html like this:

Notice that I had the variables purposely printed to see if the value was correct, and it is. If I reverse the order variables only the 'PAG' appears. Anyone have any idea what it might be?

    
asked by anonymous 01.08.2018 / 16:10

2 answers

0

I was able to find the problem, there were two requests in java / jquery that read the select and this was making the value 'NULL', I removed one of the requisitions and it worked.

    
03.08.2018 / 22:21
0

Try this:

echo "<option value='", $cd_cobr , "' selected='yes'>", $ds_cobr, "</option>";
    
01.08.2018 / 16:21