0

我从第 4 行的 Char 1 中得到了上面的错误......不知道是什么扔了它?我敢肯定它是一些我看不到的简单...

out = out + "<b>Select Box Information</b><br><br> The name of the select box is: skeletor. A play on the word selector.<br>"
out = out + "The options for the select box are, Default Value, Option 2, Option 3, Option 4 and Option 5.<br>"
out = out + "The values for each option, from top to bottom, are: " + lucy.skeletor.option(0) + ", "
out = out + lucy.skeletor.option(1) + ", " + lucy.skeletor.option(2) + ", " + lucy.skeletor.option(3)
out = out + ", " + lucy.skeletor.option(4) + ".<br><br>"
out = out + "The index of the first option in the select box is: 0. The location of the user-selected option is: " + lucy.skeletor.value + ".<br><br>"
4

2 回答 2

1

I'd think lucy.skeletor.option(1) will be the problem here. If lucy.skeletor is a genuine select element, it contains an options array. That array can be referenced like: lucy.skeletor.options[n]

furthermore, if you concatenate, you could do:

out += somestring+someotherstring+morestrings ... etc
于 2011-05-02T08:58:30.447 回答
1

out = out + ... 没问题,只是没有必要。您的问题是使用 .option(1) 访问不存在的集合

如果 skeletor 是 a 那么新浏览器的正确语法是

lucy.options[1].value 或 .text

这就是我认为你的意思

var out = "";
out += "<b>Select Box Information</b><br><br> The name of the select box is: skeletor. A play on the word selector.<br>"
out += "The options for the select box are, Default Value, Option 2, Option 3, Option 4 and Option 5.<br>"
out += "The values for each option, from top to bottom, are: "
var opts=[]; 
for (var i=0;i<lucy.skeletor.options.length;i++) opts.push(lucy.skeletor.options[0].text); 
out += opts.join(", ");
out += ".<br><br>"
out += "The index of the first option in the select box is: 0. The location of the user-selected option is: " + lucy.skeletor.value + ".<br><br>"
于 2011-05-02T09:10:25.180 回答