Good attempt to Assign the Value obtained from a query to a Database to a select
Query in Database
<?php
$lsq="SELECT DISTINCT opcion FROM tabla1";
$quer = mysqli_query($con, $lsq);
while ($raw=mysqli_fetch_array($quer)){
$opcion=$raw['opcion'];
<input type="hidden" id="opcion<?php echo $opcion; ?>" value="<?php echo $opcion;?>" >
}
?>
<td class='text-center'><a class='btn btn-info' href="#" onclick="enviar('<?php echo $numero_doc ?>')"><i class="glyphicon glyphicon-plus"></i></a></td>
This is an anchor that when pressed will get the value (option) will call me the next function
<a class='btn btn-info' href="#" onclick="enviar('<?php echo $opcion ?>')"><i class="glyphicon glyphicon-plus"></i></a>
Funcio.JS
function enviar(id)
{
var opcion= $("#opcion"+id).val();
$("#selesct").val(opcion);
}
In that function I receive the value (option) and assign it to the id of the select
Select that you should receive the value and change according to the received value
<div class="col-md-2">
<select class='form-control input-sm' id="selesct" name="selesct" readonly>
<option value="">..Seleccione..</option>
<option value="1">CONTADO</option>
<option value="2">CREDITO</option>
</select>
</div>
if the value is 1 the select should show COUNTY , if it is 2 CREDIT