`

select virtual implement

阅读更多
simple implement.
option: support input as text
not support scroll.

<html>
	<head>
		<title>select demo</title>
		<style>
			#selectText, #selectItemDiv {
				font-size: 10pt;
			}
			#selectText {
				padding-left: 7px;
				border: 0;
				width: 100px;
				height: 22px;
				line-height: 22px;
				background: url(images/select_bg.gif) no-repeat right;
			}
			
			#selectItemDiv {
				border: 1px solid #2b2bd3;
				border-top: none;
				border-radius: 0 0 10px 10px;
				height: 80px;
				overflow: auto;
				background-color: #ececf1;
			}
			#selectItemDiv ul {
				padding: 2px;
				margin: 0;
			}
			#selectItemDiv li {
				list-style: outside none;
				padding-left: 5px;
				height: 22px;
				line-height: 22px;
				cursor: default;
			}
			#selectItemDiv li:hover {
				background-color: #ccc;
			}
		</style>
		<script>
			var $=function(id){
				return document.getElementById(id);
			}
			function showItem(txt, n){
				var x=txt.offsetLeft;
				var y=txt.offsetTop;
				var w=txt.offsetWidth;
				var h=txt.offsetHeight;
				var fixY=-1;
				var fixW=-2;
				var d=$("selectItemDiv");
				if(d.style.display=="block")
					return;
				d.style.left=x+"px";
				d.style.top=y+h+fixY+"px";
				d.style.width=w+fixW+"px";
				d.style.height=22*n+4+"px";
				d.style.display="block";
				txt.style.backgroundImage="url(images/select_bg2.gif)";
			}
			function hiddenItem(li){
				var d=$("selectItemDiv");
				if(null!=li)
					$("selectText").value=li.innerHTML;
				$("selectText").style.backgroundImage="url(images/select_bg.gif)";
				$("selectText").focus();
				d.style.display="none";
			}
			function selectKey(e){
				var key=e.keyCode;
				if(13==key || 27==key)
					hiddenItem();
			}
		</script>
	</head>
	<body>
		select : <div id="selectDiv">
			<input type="text" id="selectText" onclick="showItem(this, 6)" onfocus="showItem(this, 6)" onkeyup="selectKey(arguments[0])" />
			<div id="selectItemDiv" style="position: absolute; display: none;">
				<ul>
					<li onclick="hiddenItem(this)">JAVA</li>
					<li onclick="hiddenItem(this)">HTML</li>
					<li onclick="hiddenItem(this)">JAVASCRIPT</li>
					<li onclick="hiddenItem(this)">CSS</li>
					<li onclick="hiddenItem(this)">PHOTOSHOP</li>
					<li onclick="hiddenItem(this)">ILLUSTRATOR</li>
				</ul>
			</div>
		</div>
		<hr size="1" />
		<select>
			<option value="1">1</option>
			<option value="2">a</option>
			<option value="3">b</option>
			<option value="4">2</option>
		</select>
		<br />
		<input type="text" id="txt" />
	</body>
</html>


result



to be continue...
  • 大小: 29.3 KB
分享到:
评论

相关推荐

    OpenStack.in.Action.2016.3.pdf

    You’ll learn how to select and set up virtual and physical servers, how to implement software-defined networking, and technical details of designing, deploying, and operating an OpenStack cloud in ...

    OpenStack in Action

    You'll learn how to select and set up virtual and physical servers, how to implement software-defined networking, and technical details of designing, deploying, and operating an OpenStack cloud in ...

    NDIS Filter Drivers指南

    (原文:Because filter drivers do not implement virtual miniports like an intermediate driver, filter drivers are not associated with a device object. A miniport adapter with ...

    java7帮助文档

    Oracle has two products that implement Java Platform Standard Edition (Java SE) 7: Java SE Development Kit (JDK) 7 and Java SE Runtime Environment (JRE) 7. JDK 7 is a superset of JRE 7, and contains ...

    DbfDotNet_version_1.0_Source

    DbfDotNet do not use PInvoke, Threading locks, and do not implement any transaction system. Those 3 technologies have a performance cost that it won't have to pay. In contrast it is using TypeSafe ...

    BCGControlBarPro.v12.00

    Added option to select items by clicks on grid header: New header flag BCGP_GRID_HEADER_SELECT. Implemented color themes for the new visual managers such as CBCGPVisualManager2010 (Office 2010-like...

    Senfore_DragDrop_v4.1

    * Virtual File Stream formats can only be pasted from the clipboard with live data (i.e. FlushClipboard/OleFlushClipboard hasn't been called on the data source). This problem affects ...

    Bochs - The cross platform IA-32 (x86) emulator

    - GUI: select mouse capture toggle method in .bochsrc. - Ported most of Qemu's 'virtual VFAT' block driver (except runtime write support, but plus FAT32 suppport) - Added write protect option for ...

    AD630锁相放大资料

    that is used to select the active front end. The rapid response time of this comparator coupled with the high slew rate and fast settling of the linear amplifiers minimize switching distortion. In ...

    php.ini-development

    ;;;;;;;;... 1.... 2.... 3.... 4.... 5.... 6.... The syntax of the file is extremely simple.... Section headers (e.g.... at runtime.... There is no name validation.... (e.g.... previously set variable or directive (e.g....

    i-vector的工具箱

    The Identity toolbox provides researchers with tools that implement both the conventional GMM-UBM and state-of-the-art i-vector based systems. The block diagrams below show the overall signal flow and...

    The way to go

    go程序设计语言 Contents Preface................................................................................................................................. xix PART 1—WHY LEARN GO—GETTING ...

    [Go语言入门(含源码)] The Way to Go (with source code)

    The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................

Global site tag (gtag.js) - Google Analytics