I finally decided to do the consultation in a forum, since I no longer find a way to solve the doubt I have.
I am trying to pass the chosen option of a select / option to fields that are hidden and that are autocompleted.
I've read a lot, and I've been through both JS and AJAX and php, but I can not make it work. The Case is this.
I currently have this:
<td><select class="form-control2" name="origen" id="idorigen">
<option value="0">Seleccione</option>
<?php
while($dato = mysql_fetch_array($sql)) {
echo '<option value="'.$dato['db_nombre'].'"> '.$dato['db_nombre'].' </option>';
}
?>
</select> </td>
<button onclick="mostrar()">Buscar</button>
<div id="flotante" style="display:none;" class="row" value="idorigen">
<?php
?>
<input type=text class="form-control2" id="valueanterior" value="">
</div>
<script languague="javascript">
function mostrar() {
var e = document.getElementById("idorigen");
var value = e.options[e.selectedIndex].value;
document.getElementById("valueanterior").value = value;
div = document.getElementById('flotante');
div.style.display = '';
}
function cerrar() {
div = document.getElementById('flotante');
div.style.display = 'none';
}
This shows me the option chosen as id = valueanterior. However in the floating div, I need to have the variable valueanterior to be able to perform a mysql query and get the user data, password, server, etc using this variable.
I have not found the way to do it or a better way. Try using Post, however when using post, the page refreshes and the floating div disappears, appears only when you press search, then reloads the page and disappears, for this reason it does not work for me. If someone can give me a hand it would be great. Sorry if it is not well explained, it is the first time I write in a forum and I really do not handle much. Thanks and regards