Re: onChange IE?



On Oct 4, 4:06 pm, oscar.redo...@xxxxxxxxx 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

.



Relevant Pages

  • onChange IE?
    ... I want to create a "select" by Javascript with this function: ... var sel = document.createElement; ... sel.name='propRow' + iRow; ... the onChange event is never fired? ...
    (comp.lang.javascript)
  • Re: [PHP] dynamic lists
    ... If you need a starting point, google for "javascript dynamic ... anything that uses onchange or onselect will cause ... The only way to accomplish this is using onclick ... That's typically a result of poor user requirements capture. ...
    (php.general)
  • Re: Display Text in Upper Case
    ... I am going to school this afternoon and I will try it. ... "Evertjan." ... with onchange and onkeyup the textcursor will be set to the ... I see you are in the wrong NG for Javascript. ...
    (microsoft.public.scripting.vbscript)
  • Re: Display Text in Upper Case
    ... I must have the educator enter some data as upper case. ... I have fought ... with onchange and onkeyup the textcursor will be set to the ... I see you are in the wrong NG for Javascript. ...
    (microsoft.public.scripting.vbscript)
  • Re: select onchange with typing in Webkit
    ... 'shoe' is selected, onchange does not fire ... should fire. ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)

Loading