[Javascript] help needed badly
Iztok Polanic
iztok.polanic at amis.net
Sun Dec 19 14:05:52 CST 2004
Hi!
Exactly what you said.
I want to add a <option> tag to the <select> tag in opener window. Why
should I use createElement? My solutions is also displayed at
'quirksmode' site:
copy/paste from that site:
document.forms['testform'].testselect.options[i] = new Option('new
text','new value');
What am I doing wrong?
Bye,
Iztok
Hakan M (Backbase) wrote:
> The Option constructor? I'm wondering how this can work in Firefox. What
> you want to do is create a new element of type 'option' and append it to
> your selectbox.
>
> var objSlike = opener.document.forms[0].elements['slike'];
> var oOption = document.createElement('option');
> oOption.setAttribute('value', 'theValueGoesHere');
> var oOptionContents = document.createTextNode('theTextContentGoesHere');
> oOption.appendChild(oOptionContents);
> objSlike.appendChild(oOption);
>
> Hope this helps.
>
> Regards,
> H
>
> Iztok Polanic wrote:
>
>> Hi!
>>
>> What am I dong wrong? This script works in Firefox 1.0, but IE (6.0
>> SP2) crashes!!!
>>
>> var objSlike = opener.document.forms[0].slike;
>> objSlike.options[0] = new Option('bla','bla');
>>
>> Bye,
>>
>> Iztok
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>
More information about the Javascript
mailing list