So I'm trying to write some HTML with JS, and everything I try gets me a "Syntax Error" on line 2 (even though line 2 is my <html> tag). Anyways, here's an example of what I'm doing, and must be the source of my problem:
Code:
txt[i]='<tr><td><a href="#"
onclick="toggleItem("title")">Title:</a></td><td id="title>'+title[i];
And here's the toggleItem function:
Code:
function getItem(id) //Collapsible table
{
var itm = true;
if(document.getElementById)
itm = document.getElementById(id);
else if(document.all)
itm = document.all[id];
else if(document.layers)
itm = document.layers[id];
return itm;
}
function toggleItem(id)
{
itm = getItem(id);
if(!itm)
return false;
if(itm.style.display == 'none')
itm.style.display = '';
else
itm.style.display = 'none';
return false;
}
Until I added that onclick=... the page worked fine. Any ideas? Thanks
|