0
Hello, I have the following code below, in it a Javascript function makes that when selected certain value, the tag display input
is changed, leaving it visible. It also has a PHP code, so that when the user submits the data, with some data missing, he does not miss what has already been typed. But after Submit, the tag input
back to hide, even with the OTHER value selected, someone has some idea of how to keep showing the tag after Ubmit with missing data?
<div class="form-group">
<label> Value <br />
<select class="form-group" name="value" placeholder="<?php $set1 = escape(Input::get('value')); ?>" id="value" onchange="mostraCampo(this.value);">
<option></option>
<option value="value1" <?php if ($set1 == "value1") {echo "selected='selected'";} ?>>value1</option>
<option value="value2" <?php if ($set1 == "value2") {echo "selected='selected'";} ?>>value2</option>
<option value="value3" <?php if ($set1 == "value3") {echo "selected='selected'";} ?>>value3</option>
<option value="value4" <?php if ($set1 == "value4") {echo "selected='selected'";} ?>>value4</option>
<option value="value5" <?php if ($set1 == "value5") {echo "selected='selected'";} ?>>value5</option>
<option value="NENHUMA" <?php if ($set1 == "NENHUMA") {echo "selected='selected'";} ?>>NENHUMA</option>
<option value="OUTRA" <?php if ($set1 == "OUTRA") {echo "selected='selected'";} ?>>OUTRA</option>
</select>
<input type="text" class="form-control" name="outrainst" value="<?php echo escape(Input::get('outrainst')); ?>" id="outrainst" style="display: none;">
</label>
</div>
This is Javascript to show the tag input
:
function mostraCampo(obj) {
var select = document.getElementById('value');
var txt = document.getElementById("outrainst");
txt.style.display = (select.value == 'OUTRA' || $set1 == 'OUTRA')
? "block"
: "none";
}
When you return to View with the missing data, you reload the Page?
– Matheus Cuba
@Matheuscuba I click on the button to give the submite, then the screen is reloaded, appears the messages of which data is missing, and the data that had already been filled in, but it does not show the
input
plus, only if I change the value ofoption
and go back to ANOTHER, then he comes back with the value filled before, understood more or less?– Arthur Oliveira