vendredi 6 juillet 2018

Wrapping div inside an if condition

So, I have the following div and I want to show it just if the item type is equal to "Mobile Phone" or Tablet, selected on the same page with a combo box (also an input but instead of writing it's a combobox), but I just can't figure it out how to wrap this div inside an if condition based on what is selected on the combo box, can anyone help me? Something like this: if item = "MobilePhone" or item = "Tablet" --------> Show div

But I have Php code already inside the div.. that's why i just can't do it

<div class="control-group <?php echo !empty($imeiError)?'error':'';?>">
                    <label class="control-label"><strong>IMEI</strong></label>
                    <div class="controls">
                        <input name="imei" type="text"  placeholder="IMEI" value="<?php echo !empty($imei)?$imei:'';?>">
                        <?php if (!empty($imeiError)): ?>
                            <span class="help-inline"><?php echo $imeiError;?></span>
                        <?php endif;?>
                    </div>
                 </div>

And that's how i select the input that I want

<div class="control-group <?php echo !empty($itemError)?'error':'';?>">
<label class="control-label"><strong>Item</strong></label>
<div class="controls">
    <select name="item">
        <option value="MobilePhone" <?php echo !empty($item) && $item == 'MobilePhone' ? 'selected' : ''; ?>>MobilePhone</option>
        <option value="Tablet" <?php echo !empty($item) && $item == 'Tablet' ? 'selected' : ''; ?>>Tablet</option>
        <option value="Computer" <?php echo !empty($item) && $item == 'Computer' ? 'selected' : ''; ?>>Computer</option>
        <option value="HeadPhones" <?php echo !empty($item) && $item == 'HeadPhones' ? 'selected' : ''; ?>>HeadPhones</option>
    </select>
</div>

Aucun commentaire:

Enregistrer un commentaire