联系方式

站长:
联系人:赵先生
手机:18183869808

QQ 64816414
保健茶:

联系人:罗小姐

电话:15368244381

QQ 834856496

无刷新点文本框,自动出现下拉框
发布者:zaq 类型:杂器快贴 发布时间:2018-10-16 11:00:55 浏览:3694次 [回复]
<html>
<head>
<title>add</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript">

function ShowName( sName )
{
document.getElementById('sel_class').value = sName;
}
function Div()
{
this.obj = null;
this.objWidth = 0;
this.objHeight = 0;
this.IntervalID = null;
this.bProcessing = false;
this.bOpen = false;
this.nStep = 12;

this.Init = function( sValue )
{
if( !this.obj ) return;
this.obj.innerHTML = sValue;
this.obj.style.display = 'none';
this.obj.style.position = 'absolute';
this.obj.style.overflow = 'hidden';
}
this.Show = function()
{
if( !this.bProcessing && !this.bOpen )
{
if( !this.obj ) return;
this.obj.style.width = '0px';
this.obj.style.height = '0px';
this.obj.style.display = 'block';
this.obj.style.zIndex = '1';
var self = this;
this.IntervalID = setInterval( function(){self.DoShow();},10 );
this.bProcessing = true;

//隐藏select
var oSel = document.getElementsByTagName('select');
for( i = 0; i < oSel.length; i++ )
{
//oSel[i].style.visibility = 'hidden';
}
}
}
this.DoShow = function()
{
var nWidth = this.obj.offsetWidth;
var nHeight = this.obj.offsetHeight;
var nPerX = this.nStep;
var nPerY = nPerX / ( this.objWidth / this.objHeight );
var nTempX = nWidth + nPerX;
var nTempY = nHeight + nPerY;
this.obj.style.width = nTempX + "px";
this.obj.style.height = nTempY + "px";
if( this.obj.offsetWidth >= this.objWidth || this.obj.offsetHeight >= this.objHeight )
{
this.obj.style.width = this.objWidth + "px";
this.obj.style.height = this.objHeight + "px";
clearInterval( this.IntervalID );
this.IntervalID = null;
this.bProcessing = false;
this.bOpen = true;
}
}

this.Close = function()
{
if( !this.bProcessing && this.bOpen )
{
if( !this.obj ) return;
var self = this;
this.IntervalID = setInterval( function(){self.DoClose();},10 );
this.bProcessing = true;
}
}

this.DoClose = function()
{
var nWidth = this.obj.offsetWidth;
var nHeight = this.obj.offsetHeight;
var nPerX = this.nStep;
var nPerY = nPerX / ( this.objWidth / this.objHeight );
var nTempX = nWidth - nPerX;
var nTempY = nHeight - nPerY;
if( nTempX > 0 && nTempY > 0 )
{
this.obj.style.width = nTempX + "px";
this.obj.style.height = nTempY + "px";
}
else
{
this.obj.style.display = 'none';
clearInterval( this.IntervalID );
this.IntervalID = null;
this.bProcessing = false;
this.bOpen = false;

//显示select
var oSel = document.getElementsByTagName('select');
for( i = 0; i < oSel.length; i++ )
{
oSel[i].style.visibility = 'visible';
}
}
}
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="0" width="98%" align="center" border="0">
<tbody>
<tr>
<td class="show_main">
<form onsubmit="return check()" action="?action=save" method="post">
<table cellspacing="1" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td id="errormsg" colspan="2">
</td>
</tr>
<tr>
<td class="form_label">
<label for="sel_class">
select</label>
</td>
<td class="form_input">
<input class="text" id="sel_class" onclick="oClassDiv.Show()" value="">
<div id="class">
</div>
<script type="text/javascript">
var sHTML = "<div style=\"width: 200px; height: 250px; border: 1px solid #000; background-color: #fff; position: absolute; left: 0px; top: 0px; cursor: default\">";
sHTML += "<div style=\"height: 20px; line-height: 20px; color: #fff; background-color: #a00d06; padding-left: 12px; font-weight: bold;\">";
sHTML += "select <span style=\"cursor: pointer; font-weight: normal;\" onclick=\"oClassDiv.Close();\">[close]</span></div>";
sHTML += "<div style=\"height:230px;line-height: 20px; overflow-y: scroll;\"><ul style=\"list-style: none; margin: 0;\">";
sHTML += "<li style='padding-left:12px;'><input type=radio name=class_id value=7 onclick='ShowName(\"11111\")' /> job</li>";
sHTML += "<li style='padding-left:12px;'><input type=radio name=class_id value=1 onclick='ShowName(\"22222\")' /> james</li>";
sHTML += "<li style='padding-left:12px;'><input type=radio name=class_id value=2 onclick='ShowName(\"33333\")' /> kobi</li>";
sHTML += "<li style='padding-left:12px;'><input type=radio name=class_id value=3 onclick='ShowName(\"44444\")' /> oneal</li>";
sHTML += "</ul></div>";
sHTML += "</div>";
var oClassDiv = new Div();
oClassDiv.objWidth = 202;
oClassDiv.objHeight = 252;
oClassDiv.obj = document.getElementById('class');
oClassDiv.Init( sHTML );
</script>
</td>
</tr>
</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>
源地址:http://www.zaqi.net/word_view.asp?files_id=1381
上一篇:JS限制textarea输入框输入字数的整理
下一篇:JS删除确认整理
零售:¥25元
批发:¥20元
零售:¥950元
批发:¥780元
零售:¥45元
零售:¥46元
杂器网络版权所有  免责声明