<html lang="en">
<head>
<meta charset="utf-8" />
<!-- sesuaikan dengan path jqueryui yang kamu punya -->
<link rel="stylesheet" href="jquery-ui-1.9.2.custom/themes/black-tie/jquery-ui.css" />
<script src="jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
<script src="jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
</head>
<body>
<form action="" method="post">
Nama: <input type="text" name="nama[0]" id="nama"/>
Kelas: <input type="text" name="kelas" id="kelas"/>
</br>
Nama: <input type="text" name="nama[1]" id="nama"/>
Kelas: <input type="text" name="kelas" id="kelas"/>
</br>
Nama: <input type="text" name="nama[2]" id="nama"/>
Kelas: <input type="text" name="kelas" id="kelas"/>
</form>
<script>
$(function() {
$( "#nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$('#nama').val(ui.item.nama);
$('#kelas').val(ui.item.kelas);
}
});
});
</script>
</body>
</html>
get_nama<? include ('koneksi.php');
$kode = $_GET['term'];
$sql = "select * from foto where nama like '$kode%'";
$hs = mysql_query($sql);
$json = array();
while($rs = mysql_fetch_array($hs)){
$json[] = array(
'label' => $rs['nama'],
'value' => $rs['nama'],
'kelas' => $rs['kelas']
);
}
header("Content-Type: application/json");
echo json_encode($json);
?>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- sesuaikan dengan path jqueryui yang kamu punya -->
<link rel="stylesheet" href="jquery-ui-1.9.2.custom/themes/black-tie/jquery-ui.css" />
<script src="jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
<script src="jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
</head>
<body>
<form action="" method="post">
Nama: <input type="text" name="nama[0]" id="nama-0" class="nama"/>
Kelas: <input type="text" name="kelas" id="kelas-0"/>
</br>
Nama: <input type="text" name="nama[1]" id="nama-1" class="nama"/>
Kelas: <input type="text" name="kelas" id="kelas-1"/>
</br>
Nama: <input type="text" name="nama[2]" id="nama-2" class="nama"/>
Kelas: <input type="text" name="kelas" id="kelas-2"/>
</form>
<script>
$(function() {
$( ".nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$(event.target).val(ui.item.nama);
$(event.target).next().val(ui.item.kelas);
}
});
});
</script>
</body>
</html>
<script>
$(function() {
$( ".nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$(event.target).val(ui.item.nama);
$(event.target).next().val(ui.item.kelas);
}
});
});
</script>
<script>
$(function() {
$( "#nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$('#nama').val(ui.item.nama);
$('#kelas').val(ui.item.kelas);
}
});
});
</script>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- sesuaikan dengan path jqueryui yang kamu punya -->
<link rel="stylesheet" href="jquery-ui-1.9.2.custom/themes/black-tie/jquery-ui.css" />
<script src="jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
<script src="jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
</head>
<body>
<form action="" method="post">
Nama: <input type="text" name="nama[0]" id="nama-0" class="nama"/>
Kelas: <input type="text" name="kelas[0]" id="kelas-0"/>
</br>
Nama: <input type="text" name="nama[1]" id="nama-1" class="nama"/>
Kelas: <input type="text" name="kelas[1]" id="kelas-1"/>
</br>
Nama: <input type="text" name="nama[2]" id="nama-2" class="nama"/>
Kelas: <input type="text" name="kelas[2]" id="kelas-2"/>
</form>
<script>
$(function() {
$( ".nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$(event.target).val(ui.item.nama);
$(event.target).next().val(ui.item.kelas);
}
});
});
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- sesuaikan dengan path jqueryui yang kamu punya -->
<link rel="stylesheet" href="js/themes/base/jquery.ui.all.css" />
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>
</head>
<body>
<form action="" method="post">
Nama: <input type="text" name="nama" id="nama" class="nama"/>
Kelas: <input type="text" name="kelas" id="kelas" />
</br>
Nama: <input type="text" name="nama" id="nama" class="nama"/>
Kelas: <input type="text" name="kelas" id="kelas"/>
</br>
Nama: <input type="text" name="nama" id="nama" />
Kelas: <input type="text" name="kelas" id="kelas"/>
</form>
<script>
$(function() {
$( ".nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$(event.target).val(ui.item.nama);
$(event.target).next().val(ui.item.kelas);
}
});
});
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- sesuaikan dengan path jqueryui yang kamu punya -->
<link rel="stylesheet" href="jquery-ui-1.9.2.custom/themes/black-tie/jquery-ui.css" />
<script src="jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
<script src="jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
</head>
<body>
<form action="" method="post">
Nama: <input type="text" name="nama[0]" id="nama-0" class="nama"/>
Kelas: <input type="text" name="kelas[0]" id="kelas-0"/>
</br>
Nama: <input type="text" name="nama[1]" id="nama-1" class="nama"/>
Kelas: <input type="text" name="kelas[1]" id="kelas-1"/>
</br>
Nama: <input type="text" name="nama[2]" id="nama-2" class="nama"/>
Kelas: <input type="text" name="kelas[2]" id="kelas-2"/>
</form>
<script>
$(function() {
$( ".nama" ).autocomplete({
source: "get_nama.php",
minLength: 2,
select: function( event, ui ) {
$(event.target).val(ui.item.nama);
$(event.target).next().next().val(ui.item.kelas);
}
});
});
</script>
</body>
</html>