Page 1 of 1

[SOLVED] setAttribute('eventname', 'somefun()') for Events ?

Posted: Fri Mar 04, 2005 8:51 am
by anjanesh

Code: Select all

var dropdown1 = document.createElement('select');
dropdown1.setAttribute('id', 'nameї'+someIndex+']');
dropdown1.setAttribute('name', 'name1ї]');
dropdown1.setAttribute('onchange', 'somefun()');
dropdown1.setAttribute('onchange', 'somefun()'); doesnt seem to be working - in the sense - the function is not called.
Is there some other function like setEvent() or something ?
Thanks

Posted: Fri Mar 04, 2005 8:57 am
by n00b Saibot
you can use

Code: Select all

dropdown1.onchange = somefun
instead

Posted: Fri Mar 04, 2005 10:46 am
by anjanesh
Thanks Saibot.
Sorry - dropdown1.setAttribute('onchange', 'somefun()'); did work - my mistake.

Posted: Fri Mar 04, 2005 11:07 am
by anjanesh
Sorry - I one more thing :
Why is id="id1[0]" not valid ? I thought anything anything under quotes ("") should be valid

Code: Select all

<select name="name1&#1111;]" id="id1&#1111;0]" onchange="somefun(this,0)">

Posted: Sat Mar 05, 2005 12:26 am
by n00b Saibot
Can't say for sure but AFAIK IDs can't be be array (or hashes lol) or something else. they should be just lil simple names. as distinguished from any others as paul from john ;)