Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2022, 10:41
Avatar de kaninox
kaninox
 
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Enviar valor al seleccionar texto del autocompletador

Hola, buenas estoy algo oxidado programando en jquery, tengo un input text con un autocompletador en ajax con jquery, y necesito ver la opción que cuando se seleccione

Código HTML:
Ver original
  1. <form name="formulario" method="POST" style="margin:0; padding:0;">
  2.          $(function() {
  3.             $( "#Sproduct" ).autocomplete({
  4.                source: "data.php",
  5.                minLength: 2
  6.             });
  7.            
  8.          });
  9. <div class="input-group has-validation">
  10. <input name="Sproduct" type="text" list="Sproduct" autofocus class="form-control" id="Sproduct" aria-describedby="inputGroupPrepend" autocomplete="off"  required><span class="input-group-text" id="inputGroupPrepend"><i class="bi bi-upc-scan"></i></span></form>

en el data.php tengo lo siguiente
Código PHP:
<?
$term 
$_GET"term" ];
$productos = array(
   array( 
"label" => "JAVA""value" => "1" ),
   array( 
"label" => "DATA IMAGE PROCESSING""value" => "2" ),
   array( 
"label" => "JAVASCRIPT""value" => "3" ),
   array( 
"label" => "DATA MANAGEMENT SYSTEM""value" => "4" ),
   array( 
"label" => "COMPUTER PROGRAMMING""value" => "5" ),
   array( 
"label" => "SOFTWARE DEVELOPMENT LIFE CYCLE""value" => "6" ),
   array( 
"label" => "LEARN COMPUTER FUNDAMENTALS""value" => "7" ),
   array( 
"label" => "IMAGE PROCESSING USING JAVA""value" => "8" ),
   array( 
"label" => "CLOUD COMPUTING""value" => "9" ),
   array( 
"label" => "DATA MINING""value" => "10" ),
   array( 
"label" => "DATA WAREHOUSE""value" => "11" ),
   array( 
"label" => "E-COMMERCE""value" => "12" ),
   array( 
"label" => "DBMS""value" => "13" ),
   array( 
"label" => "HTTP""value" => "14" )
    
);

$result = array();
foreach (
$productos as $producto) {
   
$productoLabel $producto"label" ];
   if ( 
strposstrtoupper($productoLabel), strtoupper($term) )!== false ) {
      
array_push$result$producto );
   }
}

echo 
json_encode$result );
?>
Lo ideal seria que al seleccionar un articulo del listado este envie el formulario de forma automatica supongo que se puede hacer con onchange? pero no se donde lo puedo agregarsi en el javascript o en el data.php de alguna forma.

Gracias de antemano.
__________________
Gokuh Salvo al mundo. PUNTO!!!!