Select boxes and "Could not convert JavaScript argument" (NS_ERROR_XPC_BAD_CONVERT_JS)
While trying to add a dynamically generated option to a select box I ran into this error:
Error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: file:///C:/Documents%20and%20Settings/mmbmb/Desktop/calendar%20de3v/calendarDateInput.js :: PickDisplayDay :: line 148" data: no]I was perplexed for some time until I did a little research and ran into this page on Quirksmode. The solution lies here:
I was trying to call the .add method of a select using text as an argument. This is non-standard (but I think works in IE). You have to instantiate an option object or else JS will error while trying to convert. Quirksmode is great btw.for(i=0;i<list.length;i+=2) { box2.options[i/2] = new Option(list[i],list[i+1]); }
2 Comments:
Thanks for the tip. I'm not a regular developer, and was using the IE method without realizing it. Guess it really is more intuitive!
This comment has been removed by the author.
Post a Comment
<< Home