/    Sign up×
Community /Pin to ProfileBookmark

2 questions about textbox editing

[B]#1[/B]ok im trying to make a wiki like thing. and i wanted to make it so it converts n’s to <br>
so i used the php str_replace(“n”, “<br>”, $source); and then fwrites it
but it doesn’t get rid of the n and when i set it equal to the javascript variable, “source”, it looks like

[code=html]var source=”text1
<br>text2
<br>”;[/code]

which results in a javascript error because it thinks its an unterminated string constant. how can i make it so I get rid of n when the page is saved.

[B]#2[/B] i also would like to know how to do the bold, italic, underline thing that is used to make posts lol. I know it has to do with document.selection(). i want it so i highlight it and press one of the 3, it puts the [B] & [/B] in the front and at the end of what i selected, and if nothing is selected it place [B][/B] wherever the text-type-dash-thing was left at. THanks!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzJun 29.2006 — [b]1)[/b] Try this instead:
preg_replace('/(rn|r|n)/', '&lt;br&gt;', $source);

[b]2)[/b] [url=http://www.faqts.com/knowledge_base/view.phtml/aid/13562]How can I manipulate the selection and the caret in an input type="text" element in Mozilla browsers and IE/Win?[/url]

http://www.alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/

http://www.massless.org/mozedit/

http://parentnode.org/javascript/working-with-the-cursor-position/
×

Success!

Help @cjm771 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...