select下拉列表长度太长,怎么控制长度 <select ... size=10 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用size控制就成了下拉框了,要显示下拉列表的 看设置style能否解决,关注一下。 <%@ page contentType="text/html;charset=GB2312" %><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>日历</title></head><body><div id="Layer1" style="position:absolute; width:160px; height:141px; z-index:1; left: 10px; top: 7px;"><style type="text/css">.body,td{font-family:"Arial";font-size:8pt;color:#ff0000;}.TrOut{background:#dddddd;height:24;border:1 solid #999999;border-top-color:#f4f4f4;border-left-color:#f4f4f4;}.TdOver{background:#eeeeee;height:20;border:1 solid #ffffff;border-top-color:#9c9c9c;border-left-color:#9c9c9c;}.TdOut{background:#eeeeee;height:20;border:1 solid #9c9c9c;border-top-color:#ffffff;border-left-color:#ffffff;}</style><script type="text/javascript">function Table(){ var sDate; //这段代码处理鼠标点击的情况 if ("TD" == event.srcElement.tagName) { //如果选中的 区域为空则不弹出窗体 即没有获取日期号 if ("" != event.srcElement.innerHTML) { //获得当前选中的日期 年 月 日 sDate = YearTD.innerText.split(' ')[0] +"年"+ MonthTD.innerText.split(' ')[0] +"月"+ event.srcElement.innerHTML +"日"; //alert("用户名不能为空!"); //获得YearTD的当前项 // var YearNO=YearTD.innerText.split(' ')[0]; //获得MonthTD的当前项 // var MonthNO=MonthTD.innerText.split(' ')[0]; alert(sDate); //window.close(); window.close(); return } }}</script><script type="text/javascript">function TableFunction(){ // this.GetDataStr=function(y,m) { //定义数组 this.DayArray=[]; //循环 将数组置空 for(var i=0;i<42;i++) { this.DayArray[i]=" "; } // for(var i=0;i<new Date(y,m,0).getDate();i++) { this.DayArray[i+new Date(y,m-1,1).getDay()]=i+1; } return this.DayArray; } // this.GetTableStr=function(y,m) { //定义新数组 并负值 this.DateArray=["日","一","二","三","四","五","六"]; // this.DStr="<table oncontextmenu='return false' onselectstart='return false' style='width:160;cursor:default;border:1 solid #9c9c9c;border-right:0;border-bottom:0;filter:progid:dximagetransform.microsoft.dropshadow(color=#e3e3e3,offx=3,offy=3,positive=true)' border='0' cellpadding='0' cellspacing='0'>\n"+ "<tr><td colspan='7' class='TrOut'>"+ "<table width='100%' height='100%'border='0' cellpadding='0' cellspacing='0'><tr align='center'>\n"+ //设置onclick事件 设置onmouseover颜色 设置onmouseout颜色 "<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"b\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>3</td>\n"+ //设置 年的 onclick事件 设置onmouseover颜色 设置onmouseout颜色 ** "<td id='YearTD' width='70' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"y\",false)'>"+y+" 年</td>\n"+ "<td id='MonthTD' width='47' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"m\",false)'>"+m+" 月</td>\n"+ //设置onclick事件 设置onmouseover颜色 设置onmouseout颜色********* "<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"n\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>4</td></tr></table>\n"+ "</td></tr>\n"+ "<tr align='center'>\n"; //循环输出数组 即"日","一","二","三","四","五","六" for(var i=0;i<7;i++) { this.DStr+="<td class='TrOut'>"+DateArray[i]+"</td>\n"; } //输出完毕 换行 this.DStr+="</tr>\n"; //嵌套循环 输出日 for(var i=0;i<6;i++) { //设置为居中 this.DStr+="<tr align='center'>\n"; for(var j=0;j<7;j++) { var CS=new Date().getDate()==this.GetDataStr(y,m)[i*7+j]?"TdOver":"TdOut"; this.DStr+="<td id='TD' class='"+CS+"' cs='"+CS+"' onclick='Table()' onmouseover='this.className=\"TdOver\"' onmouseout='if(this.cs!=\"TdOver\")this.className=\"TdOut\"'>"+this.GetDataStr(y,m)[i*7+j]+" </td>\n"; } this.DStr+="</tr>\n"; } this.DStr+="</tabe>"; return this.DStr; } this.WriteSelect=function(obj,values,action,getobj) { if(values=="")return; if(getobj) { obj.innerHTML=values+(action=="y"?" 年":" 月"); this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]); return false; } var StrArray=[]; if(action=="y") { for(var i=0;i<15;i++) { var year=values-7+i; StrArray[i]="<option value='"+year+"' "+(values==year?"selected":"")+"> "+year+"年</option>\n"; } obj.innerHTML="<select id='select1' onchange='TableFunction().WriteSelect(parentElement,this.value,\"y\",true)' onblur='YearTD.innerText=this.value+\" 年\"'>\n"+StrArray.join("")+"</select>"; select1.focus(); } if(action=="m") { for(var i=1;i<13;i++) { StrArray[i]="<option value='"+i+"' "+(i==values?"selected":"")+"> "+i+"月</option>\n"; } obj.innerHTML="<select id='select2' style='width:47' onchange='TableFunction().WriteSelect(parentElement,this.value,\"m\",true)' onblur='MonthTD.innerText=this.value+\" 月\"'>\n"+StrArray.join("")+"</select>"; select2.focus(); } } this.RewriteTableStr=function(y,m) { var TArray=this.GetDataStr(y,m); for(var i=0;i<TArray.length;i++) { TD[i].innerHTML=TArray[i]; TD[i].className="TdOut"; TD[i].cs="TdOut"; if(new Date().getYear()==y&&new Date().getMonth()+1==m&&TArray[i]==new Date().getDate()) { TD[i].className="TdOver"; TD[i].cs="TdOver"; } } } this.JumpToRun=function(action) { //获得YearTD的当前项 var YearNO=YearTD.innerText.split(' ')[0]; //获得MonthTD的当前项 var MonthNO=MonthTD.innerText.split(' ')[0]; if(action=="b") { if(MonthNO=="1") { MonthNO=13; YearNO=YearNO-1; } MonthTD.innerText=MonthNO-1+" 月"; YearTD.innerText=YearNO+" 年"; this.RewriteTableStr(YearNO,MonthNO-1); } if(action=="n") { if(MonthNO=="12") { MonthNO=0; YearNO=YearNO-(-1); } YearTD.innerText=YearNO+" 年"; MonthTD.innerText=MonthNO-(-1)+" 月"; this.RewriteTableStr(YearNO,MonthNO-(-1)); } } return this;}document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));</script></div></body></html>我这里有一个日历 你看看下拉框是怎么做的 不好意思,我没说明白,我要的是下拉列表,就是省份、市、县下拉选项的列表,由于省份要列出30个才出滚动条,太长了,所以想设置列10个后就能出滚动条滚动显示。不过还是非常感谢xinfudepangbian() 的回帖!希望有遇到这种情况的能继续回帖!先谢谢了! IE解析JSON报错,缺少 ']',chrome 浏览器正常 求此图片效果如何实现 除了 VML语言 能画图 还有其它什么吗 document.getElementById()的参数必须是常量吗?那我要动态传这个参数怎么办? 求一个正则表达式,提取字符,在线等,马上给分 求 javascript 字符替换 函数 一个表单上可以多个同名 下拉选择控件 ,做成一个数组控件吗? 如何用javascript保存网页上文本输入框的值,请高手指导! 能否button对象赋给变量?如何? js小白学习,求教,各位大佬求指导 寻找javascript教程不要jscript的 如何获得框架中页面的标题??
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>日历</title>
</head><body>
<div id="Layer1" style="position:absolute; width:160px; height:141px; z-index:1; left: 10px; top: 7px;">
<style type="text/css">
.body,td{
font-family:"Arial";
font-size:8pt;
color:#ff0000;
}
.TrOut{
background:#dddddd;
height:24;
border:1 solid #999999;
border-top-color:#f4f4f4;
border-left-color:#f4f4f4;
}
.TdOver{
background:#eeeeee;
height:20;
border:1 solid #ffffff;
border-top-color:#9c9c9c;
border-left-color:#9c9c9c;
}
.TdOut{
background:#eeeeee;
height:20;
border:1 solid #9c9c9c;
border-top-color:#ffffff;
border-left-color:#ffffff;
}
</style>
<script type="text/javascript">
function Table()
{ var sDate;
//这段代码处理鼠标点击的情况
if ("TD" == event.srcElement.tagName)
{
//如果选中的 区域为空则不弹出窗体 即没有获取日期号
if ("" != event.srcElement.innerHTML)
{
//获得当前选中的日期 年 月 日
sDate = YearTD.innerText.split(' ')[0] +"年"+ MonthTD.innerText.split(' ')[0] +"月"+ event.srcElement.innerHTML +"日";
//alert("用户名不能为空!"); //获得YearTD的当前项
// var YearNO=YearTD.innerText.split(' ')[0];
//获得MonthTD的当前项
// var MonthNO=MonthTD.innerText.split(' ')[0]; alert(sDate);
//window.close();
window.close();
return
}
}
}
</script>
<script type="text/javascript">function TableFunction()
{
//
this.GetDataStr=function(y,m)
{
//定义数组
this.DayArray=[];
//循环 将数组置空
for(var i=0;i<42;i++)
{
this.DayArray[i]=" ";
}
//
for(var i=0;i<new Date(y,m,0).getDate();i++)
{
this.DayArray[i+new Date(y,m-1,1).getDay()]=i+1;
}
return this.DayArray;
}
//
this.GetTableStr=function(y,m)
{
//定义新数组 并负值
this.DateArray=["日","一","二","三","四","五","六"];
//
this.DStr="<table oncontextmenu='return false' onselectstart='return false' style='width:160;cursor:default;border:1 solid #9c9c9c;border-right:0;border-bottom:0;filter:progid:dximagetransform.microsoft.dropshadow(color=#e3e3e3,offx=3,offy=3,positive=true)' border='0' cellpadding='0' cellspacing='0'>\n"+ "<tr><td colspan='7' class='TrOut'>"+ "<table width='100%' height='100%'border='0' cellpadding='0' cellspacing='0'><tr align='center'>\n"+ //设置onclick事件 设置onmouseover颜色 设置onmouseout颜色
"<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"b\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>3</td>\n"+ //设置 年的 onclick事件 设置onmouseover颜色 设置onmouseout颜色 **
"<td id='YearTD' width='70' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"y\",false)'>"+y+" 年</td>\n"+ "<td id='MonthTD' width='47' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"m\",false)'>"+m+" 月</td>\n"+ //设置onclick事件 设置onmouseover颜色 设置onmouseout颜色*********
"<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"n\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>4</td></tr></table>\n"+ "</td></tr>\n"+ "<tr align='center'>\n"; //循环输出数组 即"日","一","二","三","四","五","六"
for(var i=0;i<7;i++)
{
this.DStr+="<td class='TrOut'>"+DateArray[i]+"</td>\n";
}
//输出完毕 换行
this.DStr+="</tr>\n"; //嵌套循环 输出日
for(var i=0;i<6;i++)
{
//设置为居中
this.DStr+="<tr align='center'>\n"; for(var j=0;j<7;j++)
{ var CS=new Date().getDate()==this.GetDataStr(y,m)[i*7+j]?"TdOver":"TdOut"; this.DStr+="<td id='TD' class='"+CS+"' cs='"+CS+"' onclick='Table()' onmouseover='this.className=\"TdOver\"' onmouseout='if(this.cs!=\"TdOver\")this.className=\"TdOut\"'>"+this.GetDataStr(y,m)[i*7+j]+" </td>\n"; } this.DStr+="</tr>\n";
} this.DStr+="</tabe>"; return this.DStr; }
{
if(values=="")return; if(getobj)
{
obj.innerHTML=values+(action=="y"?" 年":" 月"); this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]); return false; }
var StrArray=[];
if(action=="y")
{ for(var i=0;i<15;i++)
{
var year=values-7+i; StrArray[i]="<option value='"+year+"' "+(values==year?"selected":"")+"> "+year+"年</option>\n"; } obj.innerHTML="<select id='select1' onchange='TableFunction().WriteSelect(parentElement,this.value,\"y\",true)' onblur='YearTD.innerText=this.value+\" 年\"'>\n"+StrArray.join("")+"</select>"; select1.focus(); }
if(action=="m") {
for(var i=1;i<13;i++)
{
StrArray[i]="<option value='"+i+"' "+(i==values?"selected":"")+"> "+i+"月</option>\n";
}
obj.innerHTML="<select id='select2' style='width:47' onchange='TableFunction().WriteSelect(parentElement,this.value,\"m\",true)' onblur='MonthTD.innerText=this.value+\" 月\"'>\n"+StrArray.join("")+"</select>"; select2.focus(); }
} this.RewriteTableStr=function(y,m)
{ var TArray=this.GetDataStr(y,m); for(var i=0;i<TArray.length;i++)
{ TD[i].innerHTML=TArray[i]; TD[i].className="TdOut"; TD[i].cs="TdOut"; if(new Date().getYear()==y&&new Date().getMonth()+1==m&&TArray[i]==new Date().getDate())
{ TD[i].className="TdOver"; TD[i].cs="TdOver";
} }
} this.JumpToRun=function(action)
{
//获得YearTD的当前项
var YearNO=YearTD.innerText.split(' ')[0];
//获得MonthTD的当前项
var MonthNO=MonthTD.innerText.split(' ')[0]; if(action=="b")
{ if(MonthNO=="1")
{ MonthNO=13; YearNO=YearNO-1;
} MonthTD.innerText=MonthNO-1+" 月"; YearTD.innerText=YearNO+" 年"; this.RewriteTableStr(YearNO,MonthNO-1);
} if(action=="n") {
if(MonthNO=="12")
{ MonthNO=0; YearNO=YearNO-(-1); }
YearTD.innerText=YearNO+" 年"; MonthTD.innerText=MonthNO-(-1)+" 月"; this.RewriteTableStr(YearNO,MonthNO-(-1));
} }
return this;
}
document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));</script>
</div>
</body></html>我这里有一个日历 你看看下拉框是怎么做的
不过还是非常感谢xinfudepangbian() 的回帖!
希望有遇到这种情况的能继续回帖!先谢谢了!