日期:2014-05-16 浏览次数:20922 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script src="./jQuery UI Autocomplete - Remote datasource_files/jquery-1.5.1.js"></script>
<script src="./jQuery UI Autocomplete - Remote datasource_files/jquery.ui.core.js"></script>
<script src="./jQuery UI Autocomplete - Remote datasource_files/jquery.ui.widget.js"></script>
<script src="./jQuery UI Autocomplete - Remote datasource_files/jquery.ui.position.js"></script>
<script src="./jQuery UI Autocomplete - Remote datasource_files/jquery.ui.autocomplete.js"></script>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<link rel="stylesheet" href="demos.css">
<link rel="stylesheet" href="jquery.ui.all.css">
<style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
</style>
<!--<script type="text/javascript">
$(function () {
$('input:text:first').focus();
var $inp = $(':input');
$inp.bind('keydown', function (e) {
var key = e.which;
//window.alert(e.ctrlKey);
if (key == 13||(e.ctrlKey&&key == 13)) {
e.preventDefault();
if(this.type=="submit")
{
document.forms[0].submit();
}
var nxtIdx = $inp.index(this) + 1;
$(":input:eq(" + nxtIdx + ")").focus();
}
});
});
</script>-->
<script type="text/javascript">
$(function()
{
$("#myform input:text").keypress(function(e)
{
if (e.which == 13)//判断所按是否回车键
{
var inputs = $("#myform").find(":text");//获取表单中的所有输入框
var idx = inputs.index(this);//获取当前焦点输入框所处的位置
if (idx == inputs.length - 1)// 判断是否是最后一个输入框
{
// if (confirm("最后一个输入框已经输入,是否提交?")) //用户确认
$("#myform").submit(); //提交表单
}
else
{
inputs[idx + 1].focus();//设置焦点
inputs[idx + 1].select();//选中文字
}
return false;//取消默认的提交行为
}
});
});
</script>
<script>
$(function() {
function log( message ) {
$( "<div/>" ).text( message ).prependTo( "#log" );
$( "#log" ).attr( "scrollTop", 0 );
}
var textval = $("#birds").attr("value");//
alert(textval);
$( "#birds" ).autocomplete({
//source: "search.php",
source: 'search.php?ts='+new Date().getTime()+'&k='+encodeURIComponent(textval),
//source: 'search.php?ts='+new Date().getTime()+'&k='+encodeURIComponent(ui.item.value),
minLength: 2,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
}
});
//$( "#birds