Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 05-23-2008, 12:18 PM Function in a string
Average Talker

Posts: 15
Name: Kyle
Trades: 0
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
kmoore11 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-23-2008, 12:21 PM Re: Function in a string
Average Talker

Posts: 15
Name: Kyle
Trades: 0
Well it won't let me edit that post, but I had a quote after the td id=title. I just left it out when posting, so that's not the source of my problem. I wish it was that simple

Code:
txt[i]='<tr><td><a href="#" 
onclick="toggleItem("title")">Title:</a></td><td id="title>'+title[i];
kmoore11 is offline
Reply With Quote
View Public Profile
 
Old 05-28-2008, 01:03 PM Re: Function in a string
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
There's not enough code here to diagnose the problem.

Could you add more or point us to a url?
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Function in a string
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50118 seconds with 12 queries