By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,817 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,817 IT Pros & Developers. It's quick & easy.

Textarea and tabs

P: n/a
Hi all,
Thank you in advance. Here is the issue: I need to create a page that
allows users to copy the contents of a MS Word document and paste them
into a textarea. All fine and dandy...but the tabs. I don't need to
keep the formatting, just the tabs. Is there any way to detect the tabs
and change them to four spaces or something similar? If you have any
other ideas please let me know.

Thanks again for your help,
Kent

The email address is valid and I do check it.

Oct 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Kent wrote:
Hi all,
Thank you in advance. Here is the issue: I need to create a page that
allows users to copy the contents of a MS Word document and paste them
into a textarea. All fine and dandy...but the tabs. I don't need to
keep the formatting, just the tabs. Is there any way to detect the tabs
and change them to four spaces or something similar? If you have any
other ideas please let me know.


what happens to this stuff when then user submits? goes to a php
script? then what?

you might try to use http://www.fckeditor.net/ as it does have a 'paste
word' thing that might be able to keep the tabs.

--
j

Oct 12 '05 #2

P: n/a
Kent wrote:
Hi all,
Thank you in advance. Here is the issue: I need to create a page that
allows users to copy the contents of a MS Word document and paste them
into a textarea. All fine and dandy...but the tabs. I don't need to
keep the formatting, just the tabs. Is there any way to detect the tabs
and change them to four spaces or something similar? If you have any
other ideas please let me know.

Thanks again for your help,
Kent

The email address is valid and I do check it.


Tabs are retained in the textarea when the text is pasted. encodeURI
(or 'escape' for old browsers) will replace tabs with %09 - but that
will happen anyway when the form is submitted.

<textarea onchange="alert(encodeURI(this.value))"></textarea>

decodeURI/unescape (or equivalent on your server) will restore the tabs.

--
Rob
Oct 13 '05 #3

P: n/a
Kent wrote:
Here is the issue: I need to create a page that
allows users to copy the contents of a MS Word
document and paste them into a textarea. All
fine and dandy...but the tabs. I don't need to
keep the formatting, just the tabs. Is there any
way to detect the tabs and change them to four
spaces or something similar?


This will replace tabs by 4 spaces before submitting:

<html>
<body>
<form onsubmit="
document.forms[0].i.value =
document.forms[0].i.value.replace(/\t/g,' ');
// alert(document.forms[0].i.value);
return true;"
action="script.php">

<textarea name="i" rows="20" cols="60">
[paste content from WORD here]
</textarea>
<input type="submit">
</form>
</body>
</html>

--
Bart

Oct 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.