Auto-Complete是一个脚本代码,她的作用是使在同一个form的一个input box 和 一个select box同时工作;用法是写input box的keyup事件autoComplete (text_input, select_input, ["text"|"value"], [true|false]),即可在input box数据数据就可以修改select box的对应数据,显示对应数据,代码如下:
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
// -------------------------------------------------------------------
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
// Use this function when you have a SELECT box of values and a text
// input box with a fill-in value. Often, onChange of the SELECT box
// will fill in the selected value into the text input (working like
// a Windows combo box). Using this function, typing into the text
// box will auto-select the best match in the SELECT box and do
// auto-complete in supported browsers.
// Arguments:
// field = text input field object
// select = select list object containing valid values
// property = either "text" or "value". This chooses which of the
// SELECT properties gets filled into the text box -
// the 'value' or 'text' of the selected option
// forcematch = true or false. Set to 'true' to not allow any text
// in the text box that does not match an option. Only
// supported in IE (possible future Netscape).
// -------------------------------------------------------------------
function autoComplete (field, select, property, forcematch) {
var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) { select.selectedIndex = i; }
else { select.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}
分享到:
相关推荐
auto-complete 自动完成 智能提示 代码联想 auto-complete 自动完成 智能提示 代码联想
主要包含popup-el-0.5.8.tar.gz、fuzzy-el-0.3.tar.gz和auto-complete-1.5.1.tar.gz
auto-complete 挣点分下东西。
phpstrom Phalcon auto-complete3.4.0代码提示插件
emacs-23.2-bin-i386 含cedet,auto-complete,doxymacs,yasnippet,cscope,ecb .emacs 已做基本配置
vuejs-auto-complete Vue自动完成组件npm install vuejs-auto-complete --save使用安装,将自动完成组件添加到您的应用程序中vuejs-auto-complete Vue自动完成组件npm install vuejs-auto-complete --save使用安装,...
emacs配置文件可能去我的博客(不断更新中) http://blog.csdn.net/PfanAya/archive/2011/01/16/6145504.aspx
auto-complete-clang.el
auto-complete-c-headers-源码.rar
auto-complete-clang, clang自动完整源 AC Clang Yasnippet ! 简介Clang的交流源。 结合交流。锣和Yasnippet的力量。如果你没有 Yasnippet,我建议你安装一个。 如果你不想安装 Yasnippet,你可以尝试使用 snippet....
(require 'auto-complete-c-headers) (add-to-list 'ac-sources 'ac-source-c-headers)) (add-hook 'c++-mode-hook 'my:ac-c-headers-init) (add-hook 'c-mode-hook 'my:ac-c-headers-init) 客制化 请参阅achead:...
emacs 的自动补全插件可以在写代码时自动补全
这是 Emacs 在 nXML 模式下通过 auto-complete.el 提供补全的扩展。 特征 自动开始完成 在 nXML 模式下,当您敲击开始完成默认“C-RET”的绑定键时,完成开始。 我认为这个动作在使用 Emacs 的默认界面完成时很好。...
html-tag-auto-complete 一个简单的atom编辑器程序包,可以自动完成带有/不带有类和id的html元素。 特征 没什么,但是确实可以做 只要您在其上执行的单词是有效的html标记(例如div , p , abbr等),就可以与任何...
auto-complete-address
基于Jquery的搜索框提示,可以根据需求更换ajax
composer require gkermer/nova-text-auto-complete 用法 要添加自动完成的文本字段,请在您的Nova资源中使用Gkermer\TextAutoComplete\TextAutoComplete字段: use Gkermer \ TextAutoComplete \ ...
我是怎么做的? 我使用,和<input>完成此测试。 输入字母时, onkeyup事件会触发query()处理函数以查询自动完成功能。 每个已确认的输入将作为列表条目插入到跨度中。 ...插入完成后,将为下一次插入创建新...
케이스주제 Q.동시에동시에에에출력하는출력하는출력하는출력하는출력하는출력하는능을능을능을능을。기능요구사항 de보드이벤트를지연시간(debounce기능)을请求줄인다。 리리스트는사라진다。...
关于typescript-tools,请参阅特征通过auto-complete.el自动完成popup.el的弹出帮助Eldoc.el的回声方法签名通过flymake.el检查语法跳转到定义实现继承定义 要求 安装 如果使用package.el 2013/09/10可以通过使用...