I’m getting this JS error on my code:
error: TypeError: Object #<HTMLSelectElement> has no method 'getSelected'
code:
window.addEvent('domready', function() {
$('hide_me1').setStyle('opacity', '0');
$('hide_me2').setStyle('opacity', '0');
$('recipe').addEvent('change', function() {
var opt;
opt = this.getSelected().getProperty('data-serial').toString();
if ( opt.length > 0 ) {
$('modelnumber').value = opt;
$('hide_me1').setStyle('opacity', '1');
$('hide_me2').setStyle('opacity', '1');
} else {
$('modelnumber').value = '';
$('hide_me1').setStyle('opacity', '0');
$('hide_me2').setStyle('opacity', '0');
}
});
});
Can somebody please tell me what I did wrong? I tried everything already.
Thank you
Not sure what the problem is as it seems to me the code works on this Fiddle.
It seems that in your case
thisisn’t being wrapped by MooTools. I would try changingthis.getSelectedto$(this.id).getSelected()and seeing if that works.