<!-- Script --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- jQuery UI --> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> // jakiś kod <tr> <td>nazwa</td> <td><input type='text' id='autocomplete-custom1' ></td> </tr> <tr> <td>Id</td> <td><input type='text' name="selectcustom1_id" id='selectcustom1_id' /></td> </tr> // jakiś kod <script type='text/javascript' > $( function() { $( "#autocomplete-custom1" ).autocomplete({ minLength: 2, source: function( request, response ) { $.ajax({ url: "test.php", type: 'post', dataType: "json", data: { search: request.term }, success: function( data ) { response( data ); } }); }, select: function (event, ui) { $('#autocomplete-custom1').val(ui.item.label); // display the selected text $('#selectcustom1_id').val(ui.item.value); // save selected id to input return false; } }); }); } function extractLast( term ) { } </script>
$host = "localhost"; /* Host name */ $user = "root"; /* User */ $password = ""; /* Password */ $dbname = "strona1"; /* Database name */ // Create connection $con = mysqli_connect($host, $user, $password,$dbname); // Check connection if (!$con) { } $search = $_POST['search']; $query = "SELECT * FROM test WHERE name like'%".$search."%'"; $result = mysqli_query($con,$query); while($row = mysqli_fetch_array($result) ){ } } exit;
I to działa, ale chcę drugie pole select zależne od wartości w pierwszym polu. Może jakieś linki które mi pomogą zrozumieć jak to stworzyć ?