/    Sign up×
Community /Pin to ProfileBookmark

Odd string issue

I am creating a list using onMouseOver and onMouseOut to change the background color. The first one in the list works, but for the rest firefox gives me the error “unterminated string literal document.getElement(‘c,”, which is odd…
for(i=0;i<connections.length;i++)
{
var stuff = connections[i].split(“:”);
output+=”<table class=”connection” id=”c” + stuff[0] + “” onMouseOver=”document.getElementById(‘c”+stuff[0]+”‘).style.background=’#FF9900′” onMouseOut=”document.getElementById(‘c”+stuff[0]+”‘).style.background=’#FFFFFF'” height=20px width=250px><tr><td width=50px align=”center”>”;
output+=stuff[0]+”</td><td width=100px align=”center”>”+stuff[1]+”</td><td width=100px align=”center”>”+stuff[2]+”</td></tr></table>”;
}
cbox.innerHTML = output;

I cannot see that I am doing something visibly wrong, and it is especially odd that it works for the first element but none of the rest…

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinApr 26.2006 — output is a string, you start it with " (double)

therefore the next time it sees " it will think that is the end of the string
Copy linkTweet thisAlerts:
@whakojackoauthorApr 26.2006 — output is a string, you start it with " (double)

therefore the next time it sees " it will think that is the end of the string[/QUOTE]

?? im not understanding you
Copy linkTweet thisAlerts:
@CrazyMerlinApr 26.2006 — try escaping your single quotes and see what it says
Copy linkTweet thisAlerts:
@whakojackoauthorApr 27.2006 — that didnt help. I managed to get the output from the above except a minor change so instead of a table every line its one table with a tr every line

<table width=25px class="connection" cellpadding=0 cellspacing=0 border=0><tr height=20px id="c1" onMouseover="document.getElementById('c1').style. background='#FF9900'" onMouseOut="document.getElementByld('c1').style.background='#FFFFFF'"> <td width=50px

align="center">1</td><td width=100px align="center"> 127.0.0.1</td><td width=100px

align="center">127.0.0.1</td></tr><tr height=20px id="c

0" onMouseover="document.getElementById('c

0').style.background='#FF9900'" onMouseOut="document.getElementById('c

0').style.background='#FFFFFF'"><td width=50px align="center”>

0</td><td width=100px align="center">127.0.0.1</td><td width=100px

align="center”>127.0.0. 1 </td></tr></table>

What is apparently effecting it is that the c is on one line but somehow the 0 is on the second line. It is interesting that this error only occurs on the 2nd time around and I have no clue where a n might be coming from as I have checked the output and it should be valid.
Copy linkTweet thisAlerts:
@whakojackoauthorApr 27.2006 — Nvm, found a rogue n in my server's http response. Got it now
×

Success!

Help @whakojacko spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...