IE6 issue with new Element

0 views
Skip to first unread message

elduderino

unread,
Jan 29, 2008, 11:35:37 AM1/29/08
to Ruby on Rails: Spinoffs
hi,

I have a script written using prototype at this page:

http://boudaki.com/replace/replace/replacy.php

It works fine in firefix but in IE6 i get a error....it says expected
identifier,string or number on line 11.....when i open the microsoft
script debugger it doesn't point to any line in particular. ( it
usually flags the code in fault up with a big yellow arrow) I cant
spot the problem...could anyone suggest what it is?

Heres the code...line 11 seems to be where i'm creating the a tag with
a class of select element:

//replace out the selects for un-ordered lists once the dom is fully
loaded
document.observe("dom:loaded", function() {
var forms = $$('select');
var container = $('select_container');
forms.each(function(select, index) {
select.hide();
var ul = new Element('ul', { id: 'list_' + (index +1) + '_body'});
var options = select.select("option");
options.each(function(option) {
if(option.selected == true) {
var aTag = new Element('a', { id: 'list_' + (index +1), class:
'selectelement', href:'#' }).update(option.innerHTML);
container.appendChild(aTag);
}
var li = new Element('li');
var anchor = new Element('a', {class:
'listelement'}).update(option.innerHTML);
li.appendChild(anchor);
ul.appendChild(li);
container.appendChild(ul);
ul.hide();
});
})

//now deal with the clicks
document.observe("click", function(event) {
var id = event.element().id;
var idd = event.element().className;
if(idd != 'selectelement') {
var all = $$("[id^=list_][id$=_body]");
all.each(function(eachselect) {
eachselect.hide();
})
}
var searchid = id.indexOf('list_');
if(searchid != -1) {
var assocList = id + '_body';
var listy = $(assocList);
listy.toggle();
}
if(event.element().hasClassName('listelement') ||
event.element().hasClassName('listyy')) {
event.element().className = 'listyy';
var txt = event.element().firstChild.nodeValue;
var parentSelect = event.element().up(1).id;
var getselecthead = parentSelect.replace('_body','');
var yeah = $(getselecthead);
yeah.update(txt);
var number = getselecthead.replace('list_', '');
var listhead = $$(getselecthead);
var selects = $$('select');
selects.each(function(list, index) {
if(index == (number -1)) {
var opt = list.select("option");
opt.each(function(option) {
if(option.innerHTML == txt) {
option.selected = true;
}
})
}
})
}

var tot = $$('a.listelement');
tot.each(function(lf) {
lf.observe('mouseover', function(event){
var parentSelect = event.element().up(1);
var listelements = parentSelect.select('a');
listelements.each(function(isit) {
if(isit.className == 'listyy') {
isit.className = 'listelement';
}
})
})
});
})
})
















Tobie Langel

unread,
Jan 29, 2008, 11:48:02 AM1/29/08
to Ruby on Rails: Spinoffs
class is a reserved keyword. use 'class' or className instead.

Best,

Tobie
Reply all
Reply to author
Forward
0 new messages