Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Line breaks in string containing Javascript

Reply
Thread Tools

Line breaks in string containing Javascript

 
 
Travis Pupkin
Guest
Posts: n/a
 
      12-09-2004
Hi,

I'm putting together a site to allow someone to add content to a DB
through a text area form, and then display it on the web. Pretty basic.

The problem I'm having is that they need to add snippets of javascript,
but by the time its displayed on the page, there have been extra
linebreaks added, breaking the javascript code.

Replace(string, vbCrLf,"") won't work because that removes all
linebreaks. Is there a way to preserve the original linebreaks as
submitted to the DB in the first place?

Thanks.
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      12-09-2004
Gazing into my crystal ball I observed Travis Pupkin <>
writing in news: t:

> Hi,
>
> I'm putting together a site to allow someone to add content to a DB
> through a text area form, and then display it on the web. Pretty basic.
>
> The problem I'm having is that they need to add snippets of javascript,
> but by the time its displayed on the page, there have been extra
> linebreaks added, breaking the javascript code.
>
> Replace(string, vbCrLf,"") won't work because that removes all
> linebreaks. Is there a way to preserve the original linebreaks as
> submitted to the DB in the first place?
>
> Thanks.
>


Just thinking off the top of my head, you could include another textarea
control for them to add the javascript, and then when you get _that_
field, you can do the replace.

Or, you could look for the beginning and end of the script tags, and
replace within them.

--
Adrienne Boswell
Please respond to the Group so others can share
 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      12-09-2004
The text area should send the linebreaks that are entered.

Show your database update code and the code you use to send the content back
to the client.

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Travis Pupkin" <> wrote in message
news: t...
> Hi,
>
> I'm putting together a site to allow someone to add content to a DB
> through a text area form, and then display it on the web. Pretty basic.
>
> The problem I'm having is that they need to add snippets of javascript,
> but by the time its displayed on the page, there have been extra
> linebreaks added, breaking the javascript code.
>
> Replace(string, vbCrLf,"") won't work because that removes all
> linebreaks. Is there a way to preserve the original linebreaks as
> submitted to the DB in the first place?
>
> Thanks.



 
Reply With Quote
 
Hal Rosser
Guest
Posts: n/a
 
      12-09-2004

"Travis Pupkin" <> wrote in message
news: t...
> Hi,
>
> I'm putting together a site to allow someone to add content to a DB
> through a text area form, and then display it on the web. Pretty basic.
>
> The problem I'm having is that they need to add snippets of javascript,
> but by the time its displayed on the page, there have been extra
> linebreaks added, breaking the javascript code.
>
> Replace(string, vbCrLf,"") won't work because that removes all
> linebreaks. Is there a way to preserve the original linebreaks as
> submitted to the DB in the first place?
>
> Thanks.


one way - set the "wrap" attribute of the textarea to "hard" and it
sends the data exactly as it appears in the textarea.
<textarea wrap="hard" name="codeStuff">
--- or--- tell user to enter semicolons after every javascript command
** this will work**
document.write("hello"); var myVar = 10; document.write(myVar)
**this will not work***
document.write("hello") var myVar=10 document.write(myVar) //'**(no
semicolons)
**this will work** (should include some line breaks)****
document.write(
"hello"
);




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.807 / Virus Database: 549 - Release Date: 12/7/2004


 
Reply With Quote
 
Travis Pupkin
Guest
Posts: n/a
 
      12-10-2004
In article <Ju4ud.65140$>,
says...
>
> "Travis Pupkin" <> wrote in message
> news: t...
> > Hi,
> >
> > I'm putting together a site to allow someone to add content to a DB
> > through a text area form, and then display it on the web. Pretty basic.
> >
> > The problem I'm having is that they need to add snippets of javascript,
> > but by the time its displayed on the page, there have been extra
> > linebreaks added, breaking the javascript code.
> >
> > Replace(string, vbCrLf,"") won't work because that removes all
> > linebreaks. Is there a way to preserve the original linebreaks as
> > submitted to the DB in the first place?
> >
> > Thanks.

>
> one way - set the "wrap" attribute of the textarea to "hard" and it
> sends the data exactly as it appears in the textarea.
> <textarea wrap="hard" name="codeStuff">
> --- or--- tell user to enter semicolons after every javascript command
> ** this will work**
> document.write("hello"); var myVar = 10; document.write(myVar)
> **this will not work***
> document.write("hello") var myVar=10 document.write(myVar) //'**(no
> semicolons)
> **this will work** (should include some line breaks)****
> document.write(
> "hello"
> );
>
>
>


Thanks for the tips. I'm beginning to think that it's the code itself
that is faulty, and not the way it's being submitted by the form.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search String and Delete Line Containing String Bob Hatch Ruby 3 02-01-2011 08:59 PM
inserting line breaks in text quoted in javascript alice Javascript 19 03-24-2007 01:30 AM
Beginner: read $array with line breaks line by line Marek Stepanek Perl Misc 12 09-02-2006 10:27 AM
Force multi line field value to output with line breaks? bernadou ASP .Net Web Controls 2 01-23-2006 01:23 PM
Re: javascript causing line breaks PJ ASP .Net 1 08-04-2003 12:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57