/    Sign up×
Community /Pin to ProfileBookmark

i’ve spent days searching on the web for this w/ no luck.
is there any way to take text from a form’s text box and KEEP the whitespace? everything i see tells me how to remove it and that doesn’t help at all. i want to keep the paragraphs structure EXACTLY as the user inputted.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@TheSpiritNov 22.2002 — I don't know where you're displaying the text after you take it from the box, but if you are returning it back into HTMl for them, you could have the users use HTML tags. Otherwise, formatting won't work, to my knowledge. From what I have come to understand, whitespace is killed in HTML and jscript, but I could have heard wrong. It may be possible, however, to take the text they input and return it to the user encased in a <pre> tag, which *might* save the formatting they used. That would be something like...

document.write("<pre>"+text+"</pre>")

Hope that helps... :/
Copy linkTweet thisAlerts:
@fujii13authorNov 23.2002 — i'm using aol cgi right now. i didn't know if i could generate a jscript text box or even ne other type of language to keep the formatting of the post when it was put on the message board (output) page... ?
Copy linkTweet thisAlerts:
@fujii13authorNov 23.2002 — i know some c++, but i don't know BUTT about javascript, so if i use the wrong terminology, spare me.

is there ne way to input each line into a string array one line at a time, then output each line one line at a time as well, so that i could put a manual <br> tag in between each part of the array while outputting?

something like (in c++):

int n=? // [I]number of lines inputted[/I]

string str[n]; // [I]string array[/I]


for (int j=0, j>=n, j++)

{

cout << string[j] << endl;

}

whereas "endl" in this case would be some sort of <br> in javascript.

i just noticed this after previewing my post...

i want my text box to work just like this one!

the formatting stays!

i can't decipher the javascript in the source code for this page tho, so some1 please help me out!
×

Success!

Help @fujii13 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 5.24,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...