1
Situation: We have three tables in the same form the first contains the radio button:
<td> <input required="required"
value="Evento" name="tipo" id="evento" type="radio">
<label for="tipo">Evento.</label> <input required="required" value="Viagem" name="tipo" id="viagem" type="radio">
<label for="tipo">Viagem</label></td>
At the moment is shown the two tables on the screen, I want to be shown only one that depends on the choice.
How could the if
to show a certain table?
For example
if (code){
travel table
}
if(othercode){
events table
}
It is possible to do by PHP or has to be Javascript?
I’ve tried to
<?php if($_POST['tipo']=='evento') : ?>
tabela em HTML que eu quero mostrar
<?php endif; ?>
but give me the error:
Undefined index: type
Vinicios can put the full code inside the if? And by the way, before IF the php tag is open?
– Sergio
@Sergio The complete code is very extensive but it is a table
<table>
in HTML full of inputs and the action button. the php tag was open yes. Question fixed. Thank you,– Vinicius
Okay, now I think you’re opening the tag
<?php
twice, the second inendif
– Sergio
Oops corrected once again missed
: ?>
in the question. I did so because so the HTML of <table> can be executed, the doubt now is how to pass the value of the choice of the radio button to a variable? Could be, so make the comparison and show the second or third table correctly.– Vinicius
If the radio button is changed/clicked by the user then it has to be with javascript. This is your case?
– Sergio
Yes it is! So there’s no way to do it with PHP in an if? ?
– Vinicius