4
I have a table that in each row has two checkbox options, yes and no, as shown in the image:
Code to mount the table:
$y = 0;
while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {
$tabela1 .= '<tr>';
$tabela1 .= '<td> <input type="text" readonly="true" size="20" name= "Produto['.$y.']" id= "Produto" value="'.$rows_cursos['Descricao'].'"></td>';
$tabela1 .= '<td style="float:center"> <input type="checkbox" name= "Sim['.$y.']">';
$tabela1 .= '<td style="float:center"> <input type="checkbox" name= "Nao['.$y.']">';
$tabela1 .= '<td> <textarea type="text" id="Observacao" name="Observacao['.$y.']" rows="2" cols="30"></textarea>';
$tabela1 .= '</tr>';
$y++;
}
I wanted to force to fill one of the checkboxes in each line and if one of the checkboxes was not filled, to show a warning that a line is missing.
Pq does not make it easier, only with a checkbox, if the checkbox is marked, send yes, if it is not marked send no ?
– maiconfriedel
Scupe there, this table goes inside a form ? because if it is, Html5 already has the required attribute. where you force the fill before Submit.
– Risk
@Scratchy and Doodle, it doesn’t go inside a form, it’s inside a div.
– Bruno
@Maikeaerosmith, but I want to fill a checkbox being yes or no and force the completion of one of them, because otherwise there may be an oblivion to filling and there may even be the product and register as there is no.
– Bruno
@Beginner should be able to check only one option? If you can check only "yes" or "no", use
radio button
in place ofcheckbox
with the required attribute is much easier and functional.– Máttheus Spoo
You can create the table within a form tag, and put required in the radio button sets
– Máttheus Spoo
the most indicated option, is our friend @Renan posted.
– Risk