单纯的用JAVASCRIPT不能实现吗??
解决方案 »
- =====easy ui datagrid如何添加右键菜单,实现右键删除功能?===
- vs中javascript的书写格式
- jquery贪吃蛇之后另一js游戏新鲜出炉----坦克大战(散分)
- 求助,请各位前辈看看这一段代码该怎样修改?
- 提交问题不知道为什么?
- 怎样实现一行里左上角显示一部分文本,其他地儿显示另一部分文本,意思就是说文本环绕文本。
- 请问这个是怎么加密的?解密后代码是??谢谢!
- 求一段图片跑马灯代码
- 如何用Javascript事件,删除table中的一行?
- 关于自定义属性Expression???高手Come On
- 一个问题!
- TO:karma(无为),TREEVIEW问题最后一问,^_^
function myselect(test)
{
for(var i=1;i<(test.length);i++)
if( test.options[i].text.charat(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
</script> <select name="publish" id=test onkeypress=myselect(test)>
<option value="aaaaaaaa">aaaaaaaa</option>
<option value="bbbbbbbbb">bbbbbbbbb</option>
<option value='ccccccccc'>ccccccccc</option>
</select>
也可以改成 onkeydown 再试试看
function myselect(test)
{
for(var i=1;i<(test.length);i++)
if( test.options[i].text.charat(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
</script>
你的函数text.charat(0)是不是应该改成text.charAt(0).
但是改了之后又出问题,它总是定位到A字母开头的最后一项,而不是第一项,当再按A键的时候,也不会往下移动??
function myselect(test)
{
var i;
if(test.options[test.selectedIndex].text.charAt(0)==String.fromCharCode(event.keyCode))
{
for(i=test.selectedIndex+1;i<(test.length);i++)
if( test.options[i].text.charAt(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
else
{
for(i=1;i<(test.length);i++)
if( test.options[i].text.charAt(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
}
</script>
function myselect(test)
{
var i;
if(test.options[test.selectedIndex].text.charAt(0)==String.fromCharCode(event.keyCode))
{
for(i=test.selectedIndex+1;i<(test.length);i++)
if( test.options[i].text.charAt(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
else
{
for(i=1;i<(test.length);i++)
if( test.options[i].text.charAt(0)==String.fromCharCode(event.keyCode))
{
test.selectedIndex=i;
}
}
}
</script>
**Please input the number 1-999(just for test),the number you need
will auto in the selectbox.when you select a number or not input a
number in the text,you can use the "right" key to reselect.
**
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT>
var Arraytest=new Array()
//best i=<10000
for (i=0;i<1000;i++)
{
Arraytest[i]=String(i)
}
function window_onload()
{
div1.style.visibility="hidden"
}function Find(obj)
{
n=obj.value.length
for(i=div1.children[0].options.length-1;i>=0;i--)
{
div1.children[0].remove(i)
}
for(i=0;i<Arraytest.length;i++)
{
if(Arraytest[i].substring(0,n).toLowerCase()==obj.value.toLowerCase())
{
op=document.createElement("option")
op.value=Arraytest[i]
op.text=Arraytest[i]
div1.children[0].add(op)
}
}
if(event.keyCode==40)
{
div1.children[0].focus()
div1.children[0].selectedIndex=0
}
div1.style.visibility="visible"
}
function getvalue(obj)
{
table1.rows[0].cells[0].children[0].value=obj.value
hide()
}
function getvalue1(obj)
{
if(event.keyCode==13)
{getvalue(obj)}
}
function hide()
{
div1.style.visibility="hidden"
}
</SCRIPT>
</HEAD>
<BODY onload="window_onload()">
<FORM name="AddNote">
<table border=0 id="table1">
<tr>
<td>
<input name="seltext" onkeyup="Find(this)" ondblclick="Find(this)" >
</td>
</tr>
<TR> <TD>
<div id=div1 style="z-index:1;position:absolute">
<select size=10 id=div1.children[0] style="; width:300" onclick="getvalue(this)" onkeyup="getvalue1(this)">
</select>
</div>
</TD> </TR>
</table>
</form>
</BODY>
</HTML>
[email protected]
<option value="01">Ò»</option>
<option value="02">¶þ</option>
<option value="03">ÈøÄ·</option>
<option value="04">ÈøÄ·Èý</option>
<option value="05">µÄ</option>
<option value="06">˹µÙ·Ò</option>
<option value="07" selected="">µÄ</option>
<option value="08">µØ·½1</option>
<option value="09">µØ·½2</option>
<option value="10">µØ·½3</option>
</select>
<script>
var HtmlExt=new HtmlExt;if (window.HtmlExt)
HtmlExt.makeSelectsExt(document.all.tags('select')); //Select Ext. Class
function HtmlExt() {
/**
* @description :Select¶ÔÏóµÄ¹¦ÄÜÀ©³äº¯Êý¡£µ±Select¶ÔÏó»ñµÃ½¹µã²¢ÊäÈë×Ö·ûʱ£¬
:¿ÉÒÔ×Ô¶¯¹ö¶¯µ½ÏàÓ¦µÄλÖá£
* @parameters :oSels ÒªÀ©Õ¹µÄSelect¶ÔÏ󣨻òSelect¶ÔÏóÊý×飩
* @returns :
*/
this.makeSelectsExt=function(oSels) { //public
if ((oSels!=null)&&(oSels.length))
for (var i=0;i<oSels.length;i++)
this.makeSelectExt(oSels[i]);
}
this.makeSelectExt=function(oSel) { //private
if (oSel!=null) {
oSel.attachEvent("onfocus",HtmlExt.oSelOnFocus);
oSel.attachEvent("onkeydown",HtmlExt.oSelOnKeyDown);
oSel.attachEvent("onkeypress",HtmlExt.oSelOnKeyPress);
}
}
this.oSelOnFocus=function() { //private
var oSel=event.srcElement;
oSel.inputBuf='';
}
this.oSelOnKeyDown=function() { //private
if (event.keyCode==8) { //Í˸ñ¼ü´¦Àí
event.returnValue=false;
event.cancelBubble=true;
var oSel=event.srcElement;
oSel.inputBuf=oSel.inputBuf.substr(0,oSel.inputBuf.length-1);
HtmlExt.oSelScrollByInput(oSel);
} else if (event.keyCode==46) { //ɾ³ý¼ü´¦Àí
var oSel=event.srcElement;
oSel.inputBuf="";
}
}
this.oSelOnKeyPress=function() {//private
event.returnValue=false;
var oSel=event.srcElement;
var oChar=String.fromCharCode(event.keyCode).toUpperCase();
if (oSel.inputBuf)
oSel.inputBuf=oSel.inputBuf+oChar;
else
oSel.inputBuf=oChar;
HtmlExt.oSelScrollByInput(oSel);
}
this.oSelScrollByInput=function(oSel) { //private
var oOptions=oSel.options;
if ((!oSel.inputBuf)||(oSel.inputBuf==''))
oSel.selectedIndex=0;
else
for (var i=0;i<oOptions.length;i++)
if ((oOptions[i].text.toUpperCase().indexOf(oSel.inputBuf)==0)
|| (oOptions[i].text.toUpperCase().indexOf(oOptions[i].value+' '+oSel.inputBuf)==0)
|| (oOptions[i].value.toUpperCase().indexOf(oSel.inputBuf)==0)) {
oSel.selectedIndex=i;
return i;
}
return -1;
}
} </script>
<option value="01">Ò»</option>
<option value="02">¶þ</option>
<option value="03">ÈøÄ·</option>
<option value="04">ÈøÄ·Èý</option>
<option value="05">µÄ</option>
<option value="06">˹µÙ·Ò</option>
<option value="07" selected="">µÄ</option>
<option value="08">µØ·½1</option>
<option value="09">µØ·½2</option>
<option value="10">µØ·½3</option>
</select>
如果是这样的select的话就支持!!但是如果里面的内容用一个循环从数据库里面读出来的时候,就没有了这种效果了!!