当我使用新选项更新选择框并选择所选选项时,Internet Explorer 8和7失败并显示错误。在其他浏览器中,这可以正常工作且没有错误我使用Mootools 1.2.3。

<?php
    $getdestiny=

当我使用新选项更新选择框并选择所选选项时,Internet Explorer 8和7失败并显示错误。在其他浏览器中,这可以正常工作且没有错误我使用Mootools 1.2.3。

<*>

可能是因为我使用双重分配vars opt *或者它可以是什么?请告诉我。

GET['dest']; $getcountry=

当我使用新选项更新选择框并选择所选选项时,Internet Explorer 8和7失败并显示错误。在其他浏览器中,这可以正常工作且没有错误我使用Mootools 1.2.3。

<*>

可能是因为我使用双重分配vars opt *或者它可以是什么?请告诉我。

GET['countr']; print "<script type='text/javascript'> window.addEvent('domready', function() { var countrh=$getcountry; var desth=$getdestiny; if (countrh==4){ $('destination').options.length=0; //error fails here var opt0 = $('destination').options[0] = new Option('Сhoose Destination',0); var opt1 = $('destination').options[1] = new Option('London-Aberdeen','1'); var len = $('destination').options.length; if (desth < len){ opt$getdestiny.setProperty('selected','selected'); //or here else { //do nothing } }); </script>"

可能是因为我使用双重分配vars opt *或者它可以是什么?请告诉我。

有帮助吗?

解决方案

看起来你在这里遇到了第二个错误的语法错误。

if (desth < len){
   opt$getdestiny.setProperty('selected','selected'); //or here
else {
  //do nothing
}

缺少if语句第一部分的结束}。应该是这样的:

if (desth &lt; len){
   opt$getdestiny.setProperty('selected','selected'); //or here
}else {
  //do nothing
}

<强>附录:

好的问题是你试图在一个没有包含在MooTools中的元素上使用MooTools函数。您可以通过将其包装在$()函数中来解决此问题:

$(opt$getdestiny).set('selected','selected');

我通常也只设置selected = true,所以你也可以试试。确保使用true,而不是字符串'true'。

其他提示

过去,我们已成功使用以下语法将select选项元素标记为“selected”:

option.selected = true;

在mootools 1.2中,setProperty()已被弃用。原型现在只是element.set(prop,value); - 任何东西的一个setter和一个getter(element.get()):)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top