Hello. I'm using a drop-down select box to display data from my DB. This is a part of the form code:
It works but not quite. It actually displays all the elements it is supposed to, but the choices come up blank! My selectbox drops down 3 choices, and if I choose any of them, and then I click on Submit, it saves the data on the form correctly. But why does it have to show them blank?
Is there something I can do? Thank you very much!
<select size="1" label_over="0" hide_label="0" class=" validate['required']" title="" type="select" name="input_select_8">
<?php
foreach($form->data['ListaBancos'] as $detalle):
echo "<option value=".$detalle['nombreBanco']."</option>";
endforeach;
?>
</select>
It works but not quite. It actually displays all the elements it is supposed to, but the choices come up blank! My selectbox drops down 3 choices, and if I choose any of them, and then I click on Submit, it saves the data on the form correctly. But why does it have to show them blank?
Is there something I can do? Thank you very much!
HI salamilano,
The HTML for an option is
If you look at your code in this line
you can see that it will actually output
To correct it make the line
Bob
The HTML for an option is
<option value="aaa" >bbbbb</option>
If you look at your code in this line
echo "<option value=".$detalle['nombreBanco']."</option>";
you can see that it will actually output
<option value=aaa</option>
To correct it make the line
echo "<option value='{$detalle['nombreBanco']}' >{$detalle['nombreBanco']}</option>";
Bob
This topic is locked and no more replies can be posted.