[Javascript] help needed badly

Hakan M (Backbase) hakan at backbase.com
Sun Dec 19 13:53:44 CST 2004


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

-- 
Hakan Magnusson
Senior Software Engineer
E. hakan at backbase.com
M. +31 (0)6 430 40 112

BACKBASE BV
Stephensonstraat 19
1097 BA  Amsterdam

W. http://www.backbase.com/
T. +31 (0)20 750 7305
F. +31 (0)20 750 7301

# Winner of the Broos van Erp Prize (Best High Tech Starter 2004)
# Winner of Golden SPIN Award (Innovation Prize 2003)



More information about the Javascript mailing list