Search code examples
javascripthtmlrollout

Mysterious (to me) "object doesn't support this propery or method error - JavaScript HTML rollout


I'm getting the error above from Char 1 of the 4th line... No clue what's throwing it? I'm sure its something simple that I don't see...

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>"

Solution

  • 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