Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onChange IE?

Reply
Thread Tools

onChange IE?

 
 
oscar.redondo@gmail.com
Guest
Posts: n/a
 
      10-04-2007
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!

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      10-04-2007
On Oct 4, 4:06 pm, (E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling clientside js with onchange event Zeebra3 ASP .Net 5 07-14-2007 11:12 PM
.Net validators broken by client-side script (cloneNode does not copy onchange handler) =?Utf-8?B?TW9ua2V5Qm95?= ASP .Net 2 06-05-2004 11:56 PM
need help determining the return value of a generated js onChange event MDBloemker ASP .Net 2 05-12-2004 02:45 AM
Textbox onchange won't fire after fill-in from popup window? Kathy Burke ASP .Net 1 11-10-2003 08:46 PM
POSTING A FORM USING onchange Brendan Vogt ASP .Net 2 08-28-2003 02:09 PM



Advertisments