I wish that with an "onchnge" event I could show a message without having to modify the value of a in a form.
I was asked that when I selected X value in my a text would be displayed that gave a description about the chosen option.
Currently I have sacrificed the value of elselect with a simple function to show it but I would like without losing the value to show the option (without my PHP code):
//aqui mi funcion myFunctionPuesto() me gustaria que mostrara mi resultado sin tener que usar el Value del select
<select name="idPuesto" id="myPuesto" onchange="myFunctionPuesto()" >
<?php
//$conn contiene la conecion a la base de datos
//con este script php muestro los resultados en el select en
//base a my tabla de base de datos
$sqlPuestos = "SELECT * FROM puestos";
$result = sqlsrv_query($conn,$sqlPuestos);
while($rowPuestos = sqlsrv_fetch_array($resultPuestos) ){
$idPuesto= $rowPuestos['idPuesto'];
$Puestos = utf8_encode($rowPuestos['puesto']);
$Requisitos = utf8_encode($rowPuestos['Requisitos']);
?>
<option value="<?php echo $Requisitos;?>"><?php echo $Puesto;?></option>
<?php } ?>
</select>
//aqui muestro el texto que deseo
<p id="JSpuesto"></p>
//funcion JS
<script>
function myFunctionPuesto() {
var x = document.getElementById("myPuesto").value;
document.getElementById("JSpuesto").innerHTML = "<br>" + x;
}
</script>
As I mentioned, I would like to be able to show my results based on something else that was not using the select value, because this way when using my button SUBMITH I will not be able to save my result easily :(