...

View Full Version : alternative to validation error with 'onChange'



bazz
01-17-2009, 02:33 PM
I have the following line in my html page. the validator throws an error on the onChange. what should I use instead?



<select name="combo0" id="combo_0" onChange="change(this);">


This is my doctype.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">



bazz

rangana
01-17-2009, 02:39 PM
Try to use small C:


<select name="combo0" id="combo_0" onchange="change(this);">


In XHTML, attributes must all be in lowercase.

Alternatively, you might want to separate the presentation from your markup.

You might want to assign a function to that element via:


document.getElementById('combo_0').onchange=function(){
change(this)
}


...or:


var opt=document.getElementById('combo_0');
opt.addEventListener?opt.addEventListener('change',function(){
change(this);
},false):opt.attachEvent('onchange',function(){
change(this);
}); // FF: IE


Hope that helps.

bazz
01-17-2009, 03:15 PM
thank you rangana. :thumbsup:

validates now and works too.

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum