I have a table called articles , it has the following fields: article_id , des_articulo (description of the article cited) and article (article number)
I have a form to register sanctions, where I use this table that contains the article that the person does not respect
I would like to: when changing the select options, the textbox that is on the side will change its value to the description , this being another value that is in the same table.
edit the code so that changing the select will show the ID and based on it, then convert it using the SQL QUERY . but I do not know how to do it so that with each change it is updated
<?php
include "conexion.php";
global $cone;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<title> </title>
</head>
<body>
<h1 align ="center">Bienvenido</h1>
<a href ="index.html"><ol>Pagina Principal</ol></a>
<a href ="registrar.php"><ol>Registrar</ol></a>
<a href ="listado.php"><ol>Listado</ol></a>
<a href ="Sancion.php"><ol>Sancion</ol></a>
<form method="POST" action ="procesar4.php">
<label> Ingrese cedula del sancionado</label>
<input type="text" id="cedula" name="cedula1"><br/>
<label> Ingrese cedula del sancionador</label>
<input type="text" id="cedula" name="cedula2"><br/>
<label> Ingrese tipo de sancion </label>
<div><select name="sancion">
<?php
$registros=mysqli_query($cone,"select * from sanciones");
while ($reg = mysqli_fetch_array($registros)){
echo "<option value='$reg[id_sancion]'>"."$reg[sancion]"."<br/>"."</option>";
}
?>
</select></div>
<label> Ingrese articulo inflingido </label>
<div><select name="articulo" id="articulo">
<script type="text/javascript">
jQuery(document).ready(function($) {
// Change es un evento que se ejecuta cada vez que se cambia el valor de un elemento (input, select, etc).
$('#articulo').change(function(e) {
$('#descripcion').val($(this).val());
});
});
</script>
<?php
$registros=mysqli_query($cone,"select * from articulos");
while ($reg = mysqli_fetch_array($registros)){
echo "<option value='$reg[id_articulo]'>"."$reg[articulo]"."</option>";
}
$sql =mysqli_query($cone,"SELECT des_articulo
FROM articulos
WHERE id_articulo=id_articulo");
$sql2 = mysqli_fetch_array($sql);
echo "<br/>"."<input type='text' id='descripcion' readonly value='$sql2[des_articulo]'>";
?>
</select></div>
<fieldset>
<legend>Ingrese estado de sancion</legend>
<?php
global $cone;
$registros=mysqli_query($cone,"select * from estado_sanciones");
while ($reg = mysqli_fetch_array($registros)){
echo "<label>";
echo '<input type="radio" name="estado" value="'.$reg["estado_id"].'">'.$reg["estado"];
echo "</label>";
}
?>
</fieldset>
<br/>
<label> Ingrese Fecha inicial de la sancion</label>
<div>
<script>
$( function() {
$( "#fecha1" ).datepicker();
} );
</script>
<input type="text" name="fecha1" id="fecha1"></p>
</div>
<label> Ingrese Fecha Final de la sancion</label>
<div>
<script>
$( function() {
$( "#fecha2" ).datepicker();
} );
</script>
<input type="text" name="fecha2" id="fecha2"></p>
</div>
<input type="submit" value="enviar">
</form>
</body>
</html>