`

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

    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 ...

    MFC调用Access数据库

    在类定义中,使用`DECLARE_DYNAMIC`和`IMPLEMENT_DYNAMIC`宏,并指定SQL查询来打开特定的记录集。例如: ```cpp class CMyRecordset : public CRecordset { DECLARE_DYNAMIC(CMyRecordset) public: ...

    Effective C#

    select p.Name; ``` **Item 9: Avoid Conversion Operators in Your APIs** - **Rationale:** Conversion operators can make it difficult to understand the flow of code and can introduce unexpected ...

    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 ...

    WPF 数据.pdf

    // Implement the INotifyDataErrorInfo properties and methods ... // Add validation logic ... } ``` #### 12. 从已绑定的目标属性获取绑定对象 - **定义**: 获取绑定到UI元素的绑定对象。 - **实现...

    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 ...

    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