adiddigi
Tera Guru
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
10-20-2011
03:22 AM
We had a requirement from a client asking us to populate all the options on the Service Request Form dynamically from a table.So we wrote our own UI page which will get all the options from a table.
One of the problems in writing our own UI pages with all the "fields" we want is we have to attach their event handlers and handle each and every validation 😞
In the process of validating them, we had a statement,
var element1 = document.createElement('input');
element1.type = 'checkbox';
element1.id = 'checkbox' + i;
element1.setAttribute('onclick','handlerfunction(this)');
It was working fine with Firefox, But when i tested it with IE, it wasn't working :(. One more reason for me to hate IE 😐
Reason : setAttribute doesn't work in IE.
I explored all the links that google gave me with little success.Finally, I thought of using the "observe" method of prototype.

http://www.prototypejs.org/api/event/observe
You can find everything about events in the above link. Also one of the reasons I like about prototype when it comes to event handling is, You need not pass 'this' again to a handler function.
the code is as simple as this
Event.observe(element1.id,'click',check); //Explanation is there in the link given above
and yippee it started working in IE 🙂
1 Comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.