社区
JavaScript
帖子详情
三个关于 select 的小问题[100分]
2ndboy
2003-03-10 05:26:01
(1)如何使 select 不显示滚动条?
(2)怎么知道 select 的滚动条位置发生了变化?onScroll 没有效果啊!
(3)如何使 select 不显示边框或者只显示 4 个边框中的指定几个?
...全文
106
11
打赏
收藏
三个关于 select 的小问题[100分]
(1)如何使 select 不显示滚动条? (2)怎么知道 select 的滚动条位置发生了变化?onScroll 没有效果啊! (3)如何使 select 不显示边框或者只显示 4 个边框中的指定几个?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
炜娓道来程序人生
2003-03-11
打赏
举报
回复
收藏
2ndboy
2003-03-11
打赏
举报
回复
这是我现在做出来的效果:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script laguage="JavaScript">
function OnMOver( O )
{
if( O.getAttribute( "Selected" ) == "1" )
O.bgColor = "#FF0000";
else
O.bgColor = "#0000FF";
}
function OnMOut( O )
{
if( O.getAttribute( "Selected" ) == "1" )
O.bgColor = "#00FF00";
else
O.bgColor = "";
}
function OnMClick( O )
{
if( O.getAttribute( "Selected" ) == "1" )
{
O.setAttribute( "Selected","0" );
O.bgColor = "#0000FF";
}
else
{
O.setAttribute( "Selected","1" );
O.bgColor = "#FF0000";
}
}
</script>
<style>
<!--
td { font-size: 9pt }
-->
</style>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr onMouseOver="OnMOver(this);" onMouseOut="OnMOut(this);" onClick="OnMClick(this);">
<td width="25%">Apple</td>
<td width="25%">Microsoft</td>
<td width="25%">IBM</td>
<td width="25%">CA</td>
</tr>
<tr onMouseOver="OnMOver(this);" onMouseOut="OnMOut(this);" onClick="OnMClick(this);">
<td width="25%">123</td>
<td width="25%">456</td>
<td width="25%">789</td>
<td width="25%">012</td>
</tr>
<tr onMouseOver="OnMOver(this);" onMouseOut="OnMOut(this);" onClick="OnMClick(this);">
<td width="25%">abc</td>
<td width="25%">def</td>
<td width="25%">ghi</td>
<td width="25%">jkl</td>
</tr>
</table>
</center>
</div>
</body>
</html>
有几个问题:
(1)我想在选中一项之后让其它项都不被选中,怎么遍历所有 tr 元素呢?
(2)如何为表格加上滚动条(这样看起来才象 select)
(3)改变背景色我会了,又如何改变表格文字颜色呢?
2ndboy
2003-03-11
打赏
举报
回复
如何为页面中的表格加上滚动条呢?用层吗?
fason
2003-03-11
打赏
举报
回复
1.看上面贴的代码
2.表格里面套层,style="overflow:scroll"
3.this.style.color="red"//改变为红色
fason
2003-03-10
打赏
举报
回复
<table cellpadding="0" cellspacing="0" border="0" width="100">
<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="middle">
</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" bgcolor="White">
<tr onmouseover=this.bgColor='blue' onmouseout=this.bgColor=''>
<td onclick="document.all.selectedValue.innerText=this.innerText">
1
</td>
</tr>
<tr onmouseover=this.bgColor='blue' onmouseout=this.bgColor=''>
<td onclick="document.all.selectedValue.innerText=this.innerText">
2
</td>
</tr>
<tr onmouseover=this.bgColor='blue' onmouseout=this.bgColor=''>
<td onclick="document.all.selectedValue.innerText=this.innerText">
3
</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>
2ndboy
2003-03-10
打赏
举报
回复
看来 select 可以定制的东西太少了,那就通过其它途径实现吧。
我的需求是这样的:
要显示若干数据,而每个数据又有若干域,所以最好有一个类似 ListView 的控件,所以我想用 select 做一个,现在看来不太容易。
这些显示的数据是要被提交的,所以不能用表格(虽然表格可以解决我想对齐显示的需求)。
各位大侠有何建议?
用什么方法可以做一个可以单选、可以滚动、可以多域对齐又能提交的东西?
2ndboy
2003-03-10
打赏
举报
回复
to emu_ston(emu):
(1)我就是要用 select 啊,怎么还要模拟 select?
(2)如何模拟,能说说吗?
(3)你给的例子是把四个边框都隐掉了,隐掉指定的一两个边框怎么做?我从这个例子上面实在做不到举一反三,信息太少了!
shanxing
2003-03-10
打赏
举报
回复
我想知道~~~
fason
2003-03-10
打赏
举报
回复
哎,知道的都给说完了
孟子E章
2003-03-10
打赏
举报
回复
http://lucky.myrice.com/temp/select.htm
emu_ston
2003-03-10
打赏
举报
回复
1 除非模拟select
2 onpropertychange都不行,看来也只能用模拟的。
3 被问过很多次类似的了:
<span style="position:absolute">
<select style="margin=-2">
<option>abcdefg
</select>
</span>
antd
Select
多选 限制只选中
三个
antd
select
多选
自定义
select
三角样式
select
{ /*Chrome和Firefox里面的边框是不一样的,所以复写了一下*/ border: solid 1px #000; /*很关键:将默认的
select
选择框样式清除*/ appearance:none; -moz-appearance:none; -webkit-appearance:none; /*在选择框的最右侧中间显示小箭头图片*/ background: url("http://ourjs.github.io/st
select
* from where
三个
条件_VBA学习笔记70:
Select
语句基础
学习资源:《Excel VBA从入门到进阶》第72集 by兰色幻想这节课来详细讲解
Select
语句。
Select
字段 from 表 where 条件例:从sheet1中筛选全部数据。 * 表示全部字符,无条件可以省略where。
Select
* from [sheet1$]如果是对表中特定单元格区域进行查找,可以在[sheet1$]的$后面加单元格区域。在开讲之前,先在类模块写好打开...
uniapp使用uview中自定义u-
select
三级联动、
三个
参数值
uniapp使用uview中u-
select
三级联动
select
清除右侧的小三角
关于这个
select
清除右侧的小三角 在网上找了众多方法 无外乎 用个宽度较窄的div标签包围
select
标签 然后让
select
标签 overflow:hidden; 这样基本上就可以实现
select
标签的隐藏三角了 今天偶然发现还有另一种方法 其中用到了CSS3的高级属性 不懂CSS3的盆友 赶紧恶补一下吧
select
{ -webkit-appearance: none;
JavaScript
87,992
社区成员
224,688
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章