0
I’m doing this field check <select>
and everything is going well but I would like to do the same check on a <checkbox>
who may have several possibilities then needing to work with arrays
then I don’t know how to proceed.
Below the code I use for <select>
:
PHP
if( isset( $_POST['valorminimo'] ) ) $_SESSION['valorminimo'] = $_POST['valorminimo'];
HTML
<option value="1mil" <?php echo (($valormaximo == '1mil') ? 'selected="selected"' : ""); ?>>1mil</option>
Now I have the code PHP
down to the checkboxes
that recovers the indexes correctly and need to know on HTML
how to carry out a ternary verification to apply an effect on checked
.
PHP
$dorms = isset( $_SESSION['dorms'] ) ? $_SESSION['dorms'] : array();
HTML
<input id="dorm1" class="hidden drm" type="checkbox" name="dorms[]" value="1" <?php ((in_array($dorms)) ? "checked='checked'" : "" ); ?>>
<input id="dorm2" class="hidden drm" type="checkbox" name="dorms[]" value="2">
<input id="dorm3" class="hidden drm" type="checkbox" name="dorms[]" value="3+">
In short: how to check on each
input type checkbox
if he ischecked
or not?
using foreach in
$_POST['dorms']
, checkboxes not selected or sent to the server (if I’m not mistaken)...– Vinícius Lara
Can you demonstrate in a reply please?
– Marcos Vinicius
I got lost a little, you want to do this client-side check (HTML) or server-side (PHP) because I do not see in your codes indications that these values go to the server...
– Vinícius Lara
I want to check on the return of PHP if these fields are "checked" ... take a look at this page that has the search and below the data returned from the search ... http://new.pier36imoveis.com.br/search
– Marcos Vinicius