$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
$( "#log" ).css("width","50px");
}
var file='../ajax/'+Change_ItemToBeRead();
$( "#birds" ).autocomplete({
source: file,
minLength: 1,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.label + " aka " + ui.item.label :
"Nothing selected, input was " + this.label );
$('#code').val(ui.item.id);
}
});
})
function Change_ItemToBeRead()
{
i = document.order_stop.order_class.options.selectedIndex;
i_name=document.order_stop.order_class(i).order_class_name;
if (i_name=="111"){
filename="a1.php";
}
else if(i_name=="222")
{
filename="a2.php";
}
else if(i_name=="333")
{
filename="a3.php";
}
else
{
filename="a4.php";
}
return filename;
}
<input id='birds' type='text' size=20>
<input id='code' type=hidden>
<select id='sd' onChange='Change_ItemToBeRead()'>
<option value ="111">aaa</option>
<option value ="222">bbb</option>
<option value="333">ccc</option>
</select>