从<;选择>;javascript格式
为什么我能从“Från omgång”列表中得到结果,而不是“Till omgång” 检查此右侧的过滤器按钮,并在“直到omgång”字段中选择第二个值,您将得到一个错误 我不知道为什么第二个字段中的值为null,我仔细检查了它的拼写是否正确。 HTML代码从<;选择>;javascript格式,javascript,html,Javascript,Html,为什么我能从“Från omgång”列表中得到结果,而不是“Till omgång” 检查此右侧的过滤器按钮,并在“直到omgång”字段中选择第二个值,您将得到一个错误 我不知道为什么第二个字段中的值为null,我仔细检查了它的拼写是否正确。 HTML代码 <table id="filter-menu-left"> <thead> <tr><th id="filt
<table id="filter-menu-left">
<thead>
<tr><th id="filterHead" colspan="2"> <h2>Filter</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Från omgång</td>
<td>Till Omgång</td>
</tr>
<td>
<form name='from' method='post' action='formhandler.cgi' id="to">
<select name='title' onchange='javascript:selectGamesToShowFrom();'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
</select>
</form>
</td>
<td>
<form name='to' method='post' action='formhandler.cgi'>
<select name='tit' onchange='javascript:selectGamesToShowTo();'>
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</tbody>
</table>
滤器
天哪
直到天哪
1.
2.
3.
4.
5.
6.
7.
8.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1.
2.
Java脚本
方法“selectGamesToShowFrom()”有效,但在“selectGamesToShowFrom()”方法中无法访问“to”窗体中的值。你也许能找到错误吗
function selectGamesToShowFrom(){
var from = document.from.title.value.toString();//This works
alert(from + "");
for (i=0; i<allGamesStringArray.length; i++) {
var current = parseInt(allGamesStringArray[i].substring(allGamesStringArray[i].length-2,allGamesStringArray[i].length));
var toCompareWith = parseInt(from);
if(current<toCompareWith){
allMarkersOnMap[i].setVisible(false);
//allMarkersOnMap[i].setMap(null);
}
else{
allMarkersOnMap[i].setVisible(true);
}
if(allGamesStringArray[i].indexOf(from)!=-1){
var t = parseInt(allGamesStringArray[i].substring(allGamesStringArray[i].length-2,allGamesStringArray[i].length));
}
}
}
function selectGamesToShowTo(){
var to = document.to.title.value.toString();//This gives an error that its undefined after I have selected a value in the list and I can't find the error
alert(to);
for (i=0; i>allGamesStringArray.length; i++) {
var current = parseInt(allGamesStringArray[i].substring(allGamesStringArray[i].length-2,allGamesStringArray[i].length));
var toCompareWith = parseInt(from);
if(current>toCompareWith){
allMarkersOnMap[i].setVisible(false);
}
else{
allMarkersOnMap[i].setVisible(true);
}
if(allGamesStringArray[i].indexOf(from)!=-1){
alert("hejdar");
var t = parseInt(allGamesStringArray[i].substring(allGamesStringArray[i].length-2,allGamesStringArray[i].length));
}
}
}
函数selectGamesToShowFrom(){
var-from=document.from.title.value.toString();//这很有效
警报(从+“”);
对于(i=0;i
应该是
var to = document.to.tit.value.toString();
但是,正如您所指出的,一些浏览器仍然不满意。Opera不喜欢表单名为to
,将其更改为toForm
,并相应地更新您的代码使Opera再次满意。假设您的意思是var to=document.to.tit.value.toString();仍然不起作用,获取该值是否为null对象:/a对我有效。您可以更新演示吗?一旦超过该行,可能会出现第二个错误。它会提醒所选值,因此document.to.tit.value.toString()
有效。是的,它在firefox和crome中有效,但该函数不起作用,而且我在Explorer中仍然会出现错误,因此有些可疑。不过无论如何,谢谢=)我暗自怀疑,将表单命名为<代码>可能会导致问题,这似乎会使Opera出错,因此我建议使用不同的名称,以确保所有主要浏览器都返回选定的值。如果无法调试函数逻辑,则应发布新问题。
var to = document.to.tit.value.toString();