I found this code online and did some editing to make it pull data from my database rather that from the file itself.
Anyhow, I'm not an expert by any means with Javascript and I would like to have two text boxes. The second one will be uneditable and will be autofilled once the model is selected. At the moment the database table only has two fields and I would like to have the second text box autofilled with that second column, ID.
Can anyone help me out with this. It would be greatly appreciated.
<!doctype html>
<?php
include('mysql_connect.php');
$arr = array();
$sql = "select model from models";
$result = mysql_query($sql) or die(mysql_error());
while( $row = mysql_fetch_assoc( $result ) ) {
$test = implode($row, ',');
$arr[] = '"'.$test.'"';
}
echo '<pre>';
$test = implode($arr, ',');
echo $test;
echo '</pre>';
?>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
<?php echo $test; ?>
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input type="text" id="tags" />
</div>
</body>
</html>