By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,510 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

builder.node('select'..) selected not working solution

P: n/a
FYI,

with something like this:

hotelement = "hotelement"+hotcount;

hotspot = Builder.node('div', { id:'hotspot'+hotcount,
className:'hotspot', style:''+divstyle }, [
Builder.node('select', {id:hotelement, onChange:hotspotlink}, [
Builder.node('option',{value:'textfield',
selected:''},"textfield"),
Builder.node('option',{value:'textarea'},"textarea "),
Builder.node('option',{value:'dropdown'},"dropdown "),
Builder.node('option',{value:'checkbox'},"checkbox "),
Builder.node('option',{value:'number'},"number"),
Builder.node('option',{value:'date'},"date"),
Builder.node('option',{value:'time'},"time")
])
]);

$('column_container').appendChild( hotspot );

$(hotelement).selectedIndex = 1;

the

$(hotelement).selectedIndex = 1;

fixes the problem

Aug 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
sicapitan wrote:
<snip>
Builder.node('option',{value:'textfield', selected:''},"textfield"),
Because you are not including the code for the objects/method/functions
being used here it is impossible to tell what these 'parameters' are
intended for, but it seems likely that whether - selected - is destined
to be an element property or an attribute (unlikely given the poor
support on IE) the value of an empty string would be a useful value to
be using. If the intention is to set a - selected - property of the
element then because the empty string type-converts to boolean false
when assigned to a boolean element value the result would be an option
that was _not_ selected, and the only value for a selected attribute is
the string "selected".

<snip>
$(hotelement).selectedIndex = 1;

the

$(hotelement).selectedIndex = 1;

fixes the problem
What problem? Not by any chance the problem that you expect the second
option to be selected and that is not the case without the explicit
assignment to the selectedIndex?

Richard.

Aug 23 '06 #2

P: n/a
i made a mistake, selected:'selected'

its a bug in FF apparently, mentioned elsewhere, setting the index
fixes it

problem was no option was selected, and it would jump to the last, as
the builder code would write selected='selected' with no defaults to a
blank value.

cheers
r

Richard Cornford wrote:
sicapitan wrote:
<snip>
Builder.node('option',{value:'textfield', selected:''},"textfield"),

Because you are not including the code for the objects/method/functions
being used here it is impossible to tell what these 'parameters' are
intended for, but it seems likely that whether - selected - is destined
to be an element property or an attribute (unlikely given the poor
support on IE) the value of an empty string would be a useful value to
be using. If the intention is to set a - selected - property of the
element then because the empty string type-converts to boolean false
when assigned to a boolean element value the result would be an option
that was _not_ selected, and the only value for a selected attribute is
the string "selected".

<snip>
$(hotelement).selectedIndex = 1;

the

$(hotelement).selectedIndex = 1;

fixes the problem

What problem? Not by any chance the problem that you expect the second
option to be selected and that is not the case without the explicit
assignment to the selectedIndex?

Richard.
Aug 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.