给一个点击输入框即出现相应弹出菜单的源码!急!!!

farawayMemory 2003-04-14 10:41:14
多谢!
...全文
48 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
possible_Y 2003-05-16
  • 打赏
  • 举报
回复
或者:


<span>
<input name=iData size=10><input type=button onclick=showSel(true) value=v>
<br/><select id=qswh size=10 style=position:absolute;display:none onchange=selText(iData)>
<option>1
<option>12
<option>123
<option>1234
<option>12345
<option>123456
<option>1234567
<option>12345678
<option>123456789
<option>1234567890
<option>12345678909
<option>123456789098
<option>1234567890987
<option>12345678909876
<option>123456789098765
<option>1234567890987654
<option>12345678909876543
<option>123456789098765432
<option>1234567890987654321
</select>
</span>ttt
<script>
function document.onclick(){
showSel(false)
}
function showSel(flag){
document.all.qswh.style.display=(flag?"block":"none")
window.event.cancelBubble=true;
}
function selText(obj){
obj.value=(document.all.qswh.options[document.all.qswh.selectedIndex].text)
//showSel(false)
}
</script>
possible_Y 2003-05-16
  • 打赏
  • 举报
回复
<table cellpadding="0" cellspacing="0" border="0" width="300">
<tr>
<td id="selectLength" width="100%" style="height:20px;padding:0px;border:2px inset #404040;border-right:0px;border-bottom:1px solid #D4D0C8;font-size:9pt;">
<div id="selectedValue" style="padding:2px;border:0px;width:100%;height:20px;font-size:9pt;vertical-align:bottom"></div>
</td>
<td width="20" style="height:20px;padding:0px;border-top:2px inset #404040;border-left:0px;border-right:1px solid #D4D0C8;border-bottom:1px solid #D4D0C8;font-size:9pt">
<img src="button2.gif" width="20" height="21" border="0" id="mm" onclick="mm_Click()" align="absmiddle">
</td>
</tr>
</table>
<div id="dropdownOption" style="position:absolute;visibility:hidden;width:100%;border:1px solid #080808;z-index:1000">
<table width="100%" cellpadding="0" cellspacing="1" class="optionForSel" bgcolor="White">
<tr onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''">
<td onclick="document.all.selectedValue.innerText=this.innerText">
<img src="http://lucky.myrice.com/images/copyright.gif" border="0" align="absmiddle" hspace="2"><a href="http://lucky.myrice.com">Visit1</a>
</td>
</tr>
<tr>
<td onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''"onclick="document.all.selectedValue.innerText=this.innerText">
<img src='http://lucky.myrice.com/images/meng1.gif' border="0" align="absmiddle" hspace="2"><a href="http://lucky.myrice.com">Visit2</a>
</td>
</tr>
<tr>
<td onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''"onclick="document.all.selectedValue.innerText=this.innerText">
<img src='http://lucky.myrice.com/images/meng2.gif' border="0" align="absmiddle" hspace="2"><a href="http://lucky.myrice.com">Visit3</a>
</td>
</tr>
</table>
</div>

<script>
function mm_Click()
{
if(document.all.dropdownOption.style.visibility == 'visible')
document.all.dropdownOption.style.visibility='hidden'
else
document.all.dropdownOption.style.visibility='visible'
}
function init(){
document.all.dropdownOption.style.width = document.all.selectLength.clientWidth + 22;
document.all.selectedValue.contentEditable = true;
var strTop = 0;
var strLeft = 0;
var e1 = document.all.selectLength;
while(e1.tagName != "BODY")
{
strTop += e1.offsetTop
strLeft += e1.offsetLeft
e1 = e1.offsetParent
}
document.all.dropdownOption.style.top = String(strTop + 24) + "px";
document.all.dropdownOption.style.left = String(strLeft) + "px";
}

function clickE()
{
if(window.event.srcElement.id !='mm')
document.all.dropdownOption.style.visibility='hidden';
}

document.onclick = clickE
window.onload = init
</script>
<br>
<br>
<input onclick="alert(document.all.selectedValue.innerText)" type="button" value="得到选中的值">
JK_10000 2003-04-14
  • 打赏
  • 举报
回复
刚才理会错误,对不起
JK_10000 2003-04-14
  • 打赏
  • 举报
回复
是不是弹出菜单文件名取得有问题?
farawayMemory 2003-04-14
  • 打赏
  • 举报
回复
JK_10000(JK1)兄,多谢GZ,来者有分

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧