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
My Javascript doesn't work with line breaks?
Old 08-01-2010, 09:09 AM My Javascript doesn't work with line breaks?
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
So I have a simple quote script, meaning you can click 'Quote' and it will grab the author and content of the post and put it in the quick reply box. I can get it to do that with one line posts... But not with multiple line posts.

Meaning that the post 'asdfasdf hadsfjhashdfh 01 DF ADF' would work, but 'asdf

132 adf
1
dfa'

won't .

Here is my simple script and example for calling it, if you know what's wrong please say

HTML Code:
<script type="text/javascript">
function quoteMe(author,content) {
    document.getElementById('replyContent').innerHTML+="[quote="+author+"]"+content+"[/quote]";
}
</script>
<a href='#new' onclick=\"quoteMe('".$row['author']."','".$row['replyContent']."');\" style='font-weight:700;margin-top:-10px;float:right;clear:right;'>Quote</a>
The reason the HTML is weird is because it's in a PHP echo statement inside a MySQL while query.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 08-01-2010 at 09:10 AM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-01-2010, 12:13 PM Re: My Javascript doesn't work with line breaks?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Add /n into the string where you want a line break.

replace '<br>' with '/n' to maintain formatting

and replace '/n' with '<br>' to display the breaks.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-01-2010, 09:31 PM Re: My Javascript doesn't work with line breaks?
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Alright, cool. Thanks, I will try that when I get the chance (writing from non-dev comp)
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to My Javascript doesn't work with line breaks?
 

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.54965 seconds with 12 queries