Select does not load the options directly

Asked

Viewed 40 times

-1

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

I’m using php to load a select and bring the answer in 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 like this a million times, but since yesterday he’s been loading html like this:

inserir a descrição da imagem aqui

Notice that I purposely printed the variables to see if the value was correct, and it is. If I invert the order variables only show the PAG. Does anyone have any idea what it might be?

2 answers

0

Try it this way:

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

0


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

Browser other questions tagged

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