These are my two inputs:
<div class="span3">
<label for="cor11">CROMIA<span class="required"></span></label>
<select class="span12" name="cor11" id="cor11" onchange="validarForm()" value="">
<option <?php if($result->cor11 == 'Selecione a Cor'){echo 'selected';} ?> value="Selecione a Cor">Selecione a Cor</option>
<option <?php if($result->cor11 == '-'){echo 'selected';} ?> value="-">-</option>
<option <?php if($result->cor11 == 'CYAN'){echo 'selected';} ?> value="CYAN">CYAN</option>
<option <?php if($result->cor11 == 'MAGENTA'){echo 'selected';} ?> value="MAGENTA">MAGENTA</option>
<option <?php if($result->cor11 == 'YELLOW'){echo 'selected';} ?> value="YELLOW">YELLOW</option>
<option <?php if($result->cor11 == 'BLACK'){echo 'selected';} ?> value="BLACK">BLACK</option>
</select>
</div>
<div class="span3">
<label for="cor12">COR ESPECIAL/PANTONE</label>
<input id="cor12" disabled class="span12" type="text" name="cor12" style="text-transform:uppercase" value="<?php echo $result->cor12 ?>" />
</div>
The input cor12
is disabled by choosing the input cor11
.
If the choice in cor11
is "-", enable input of cor12
. Script below:
function validarForm() {
var optionSelect = document.getElementById("cor11").value;
if(optionSelect =="-" ){
document.getElementById("cor12").disabled = false;
}else{
document.getElementById("cor12").disabled = true;
}
}
When editing, it even runs POST
and saves it in the DB.
However, if I go back to editing, and make a change in any field, the information from these two inputs is erased from the DB.
What happens?