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
Passing a carriage return as part of an argument/text string
Old 04-26-2007, 04:49 PM Passing a carriage return as part of an argument/text string
Super Talker

Posts: 116
Trades: 0
Hi there...

I wrote a function that will inserts a list item somewhere in the middle of the list (technically, it's right before the list item that is marked with an id="something")

Here it is...

function addListItem(lcTag, lcText, lcClassName) {

var currentNode = document.getElementById(lcTag);
var list = currentNode.parentNode;
var newNode = document.createElement("li");
var spanNode = document.createElement("span");

var newTextNode = document.createTextNode(lcText);
spanNode.appendChild(newTextNode);

if (lcClassName)
{
spanNode.className=lcClassName;
}

newNode.appendChild(spanNode);
list.insertBefore(newNode, currentNode);

}

Here's how the function would be passed...

addUserListItem('before this item', 'For more information, check out our help page', 'black')

My problem is that I may want to break the lcText string into two lines. Is there a way to pass this through the argument?

Thanks
Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-26-2007, 05:44 PM Re: Passing a carriage return as part of an argument/text string
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
simply add an "<br/>" tag in the parameter you give to your function. As it is HTML, it will interpret the tag as a line break.
Code:
addUserListItem('before this item', 'For more information, check out <br/>our help page', 'black');
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-27-2007, 10:05 AM Re: Passing a carriage return as part of an argument/text string
Super Talker

Posts: 116
Trades: 0
Tripy,

Thanks for responding... but it doesn't work. It'll pass the <br /> as part of the copy.

I even tried to isolate the <br /> by sending it within double quotes when passing a single quote string... didn't work.

DonnaZ
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 04-27-2007, 10:32 AM Re: Passing a carriage return as part of an argument/text string
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Did you tried this ?
Code:
&gt;br/&lt;
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-27-2007, 05:58 PM Re: Passing a carriage return as part of an argument/text string
Super Talker

Posts: 116
Trades: 0
I will tonight...

Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Passing a carriage return as part of an argument/text 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.15517 seconds with 12 queries