checkboxlist - items on change event

J

Jason Hartsoe

i've tried to add an onchange event to my checkboxes(created dynamically)

chkboxlist.attributes.add("onchange", "dothat();")

but it renders the onchange to the table it creates and not to the list
items. I need to add the onchange event to all the checkbox(s) that are
created dynamically. I've even tried

dim li as ListItem
for each li in chkboxlist
li.attributes.add("onchange", "dothat();")
next

but it still renders to the table that the chkboxlist creates rather than
the items.

Can this be done? If so can someone give some good examples?


thanks!

jason
 
A

Alex Kudryashev

Jason Hartsoe said:
i've tried to add an onchange event to my checkboxes(created dynamically)

chkboxlist.attributes.add("onchange", "dothat();")

but it renders the onchange to the table it creates and not to the list
items. I need to add the onchange event to all the checkbox(s) that are
created dynamically. I've even tried

dim li as ListItem
for each li in chkboxlist
li.attributes.add("onchange", "dothat();")
next

but it still renders to the table that the chkboxlist creates rather than
the items.

Can this be done? If so can someone give some good examples?


thanks!

jason
Do it on the Client side.
<script type="text/javascript">
var chks = document.getElementsByName('checkboxlist');
if(chks && chks.length)
for(var i=0,N=chks.length; i<N; i++)
chks.onclick=dothat;

function dothat() {//your code}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top