![]() |
onChange IE?
Hi!
I want to create a "select" by Javascript with this function: function cargaOpciones(iRow) { var i var sel = document.createElement('select'); i=0 sel.name='propRow' + iRow; sel.id='propRow' + iRow; sel.onChange="alert('Change');"; while (i<document.forms[0].cboOpciones.options.length) { sel.options[i]=new Option(i,i) i=i+1; } return sel } Unfortunatelly, the onChange event is never fired? Anyone can help me? Thanks in advance! |
Re: onChange IE?
On Oct 4, 4:06 pm, oscar.redo...@gmail.com wrote:
> Hi! > > I want to create a "select" by Javascript with this function: > > function cargaOpciones(iRow) > { > var i > var sel = document.createElement('select'); > > i=0 > sel.name='propRow' + iRow; > sel.id='propRow' + iRow; > sel.onChange="alert('Change');"; Javascript is case sensitive, even if HTML isn't - so use onchange. And to satisfy a wider range of browsers, you need to assign a function object or reference to the onchange property: sel.onchange = function(){alert('Change');} though using onchange with a select element has usability issues. > > while (i<document.forms[0].cboOpciones.options.length) That would be more efficient as: var j = document.forms[0].cboOpciones.options.length; while (i<j) > { > sel.options[i]=new Option(i,i) > > i=i+1; Why not: i++; -- Rob |
| All times are GMT. The time now is 03:37 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.