我想在使用javascript的下拉列表中有多个值,因此不需要在选择标记的选项中写入太多值,因此我使用下面的代码来执行此操作,但它是当在Internet Explorer中打开时显示不可见值意味着分配的空间是可见的但不是内容,在Chrome浏览器中它不显示任何内容。在下拉列表中获取不可见的值
<script>
function Time(){
selectHr();
selectMin();
selectSec();
}
function selectHr()
{
for(var x=1;x<=24;x++)
{
var option = document.createElement("option");
option.text = x;
option.value=x;
document.getElementById('dateTime_selHr').add(option);
}
}
function selectMin()
{
for(var x=1;x<=60;x++)
{
var option = document.createElement("option");
option.text = x;
option.value=x;
document.getElementById('dateTime_selMin').add(option);
}
}
function selectSec()
{
for(var x=1;x<=60;x++)
{
var option = document.createElement("option");
option.text = x;
option.value=x;
document.getElementById('dateTime_selSec').add(option);
}
}
</script>
</head>
<body onload="Time()">
<table class="table" id="dateTime_tbl">
<tr>
<td>
Camera
</td>
<td colspan="2">
<input type="text" name="camera" />
</td>
</tr>
<tr>
<td>
Time In Camera Date
</td>
<td>
Date <input type="text" name="date"/>
Time <input type="text" name="time" />
</td>
</tr>
<tr>
<td> Set Time</td>
<td>
<input type="radio" /> Set manually
</td>
</tr>
<tr>
<td></td>
<td>Date <input type="text" name="txtdate" />
Time
hr : <span> <select name="hr" id="dateTime_selHr"> </select> </span>
min : <span> <select name="min" id="dateTime_selMin" > </select> </span>
sec : <span> <select name="sec" id="dateTime_selSec" > </select> </span>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="syncTime" />Synchronize with computer time
</td>
</tr>
<tr>
<td></td>
<td>
Date <input type="text" />
Time <input type="text" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" /> Synchronize with SNTP server
</td>
</tr>
<tr>
<td></td>
<td>
SNTP Server <input type="text" style="width:200px"/>
</td>
</tr>
<tr>
<td></td>
<td>
Time Zone <span> <select name="timeZone">
<option></option>
</select></span>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" /> Automatically adjust for daylight saving time changes
</td>
</tr>
<tr>
<td>
Date Format <span><select>
<option>-select-</option>
<option>YYYY/MM/DD</option>
<option>MM/DD/YYYY</option>
<option>DD/MM/YYYY</option>
</select></span>
</td>
<td>
Time Format <span> <select>
<option>-select-</option>
<option>12 hour format</option>
<option>24 hour format</option>
<option>DD/MM/YYYY</option>
</select></span>
</td>
</tr>
<tr>
<td>
Date Position <span><select>
<option>-select-</option>
<option>Bottom Left</option>
<option>Bottom Right</option>
</select></span>
</td>
<td>
Time Position <span> <select>
<option>-select-</option>
<option>Bottom Left</option>
<option>Bottom Right</option>
</select></span>
</td>
</tr>
</table>
<center>
<div id="dateTime_actionBtnsDiv">
<button type="button" name="ok" style="width:80px" id="dtTime_btns">OK</button>
<button type="button" name="cancel" style="width:80px" id="dtTime_btns">CANCEL</button>
</div>
</center>
</body>
有人可以帮我解决这个问题吗?
可以让我们知道什么叫'隐形values'是什么意思? –
我测试了你的代码。它似乎工作正常。你遇到了什么错误 ? – SpiderCode
@SpiderCode在IE 9对我来说,它显示错误OP状态:http://fiddle.jshell.net/tR2GC/show/ – Ming