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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

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

Post 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
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

you can use

Code: Select all

dropdown1.onchange = somefun
instead
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Thanks Saibot.
Sorry - dropdown1.setAttribute('onchange', 'somefun()'); did work - my mistake.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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)">
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 ;)
Post Reply