sorry to post what i'm sure is a simple questin but I am trying to get data from a database and then based on a simple searh fill in a form. On my quest for this I found this example. JSFiddle.
This seems to be more or less what I want if I expand to my database size. But for the life of me I cannot even get that script working before I have tried adapting it! I always have trouble with getting javascript and Jquery to work so thoigh I woul dask incase its something stupid i'm doing.
So I have placed jquery 1.7.2 and 1.8.16 UI in within my headlike so
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.21/themes/black-tie/jquery-ui.css" type="text/css" media="screen" />
and then placed this code in my body
<script>
var src = [{
"label": "Jack",
"value": "1"
}, {
"label": "back",
"value": "2"
}, {
"label": "tera",
"value": "3"
}, {
"label": "judo",
"value": "4"
}];
$('.name').change(function() {
$('.value').val(0);
});
$(".name").autocomplete({
source: src,
select: function (event, ui) {
event.preventDefault();
this.value = ui.item.label;
$('.value').val(ui.item.value);
}
});
</script>
<input type="text" class="name" />
<input type="text" class="value" />
Thats it! Exactly the same as the JSfiddel example and yet it does not work. Any ideas?
Like I said, I seem to always have issue with javascript and Jquery codes and would bery much like to get to the bottom of what I do wrong.
Any help appreciated.
Ian