Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string concatenation problem.

Status
Not open for further replies.

uncLez

Programmer
Jun 18, 2002
38
NL
Ok, as far as I know, this should work. But for osme reason all I get in the status bar is: javascript:eek:bjLocalMenu.toggleExpand(

the script line:
Code:
strHTML = strHTML + &quot;<a href='javascript:objLocalMenu.toggleExpand('&quot; + this.id + &quot;')'>&quot; + this.text + &quot;</a>&quot;;

What could cause a problem like this? Running the script does not return any errors in the form of unterminated strings etc...

Thanx in advance,
Anton.
 
Your single and double quotes aren't balanced for use in a status bar:

strHTML += '<a href=&quot;javascript:eek:bjLocalMenu.toggleExpand(\'' + this.id + '\')&quot;>' + this.text + &quot;</a>&quot;;

 
That was exactly the problem.

Thanx! \:)/
 
As further explanation, you can count your quotes like:

double quote open, single quote open, single quote close, double quote close,

which is what you have. You CANNOT have 2 single quote opens or 2 double opens, since the second single or double quote closes the opening one of the same type:

&quot; <a href= ' javascript:eek:bjLocalMenu.toggleExpand( ' &quot; + this.id + &quot; ' ) ' > &quot; + this.text + &quot;</a>&quot;;

By using the escape character (\), you tell Javascript to treat the following quote as a literal character in the string. By switching around the sequence of single and double quotes in your string, you can get the results you want, but not the way you originally had written it.
 
For some reason I can't seem to flag your post as helpful or expert, but if I could I woulda.

Thanx a bunch!
 
I'm not an official member, and you can only give stars to members. Thanks anyway. :)# (bearded smiley face)
 
yeah troll, why aren't you a member? you'd have a couple thousand stars already.
======================================

if (!succeed) try();
-jeff
 
Thanks for your compliments, Gary and Jeff. Like I told Gary once before, I'm still undecided about joining the human race. :)#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top