473,545 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a textarea where some text is in a different color

I want to do this:

<textarea>
perl
<font color="FF0000">
$thing_to_get=1 7;
</font>
More Perl code using $thing_to_get
</textarea>

But the above doesn't work, of course.

The idea is that I'm giving the users a bunch of text where they might
want to edit the red parts. Then I'll have a javascript button to
select all. A user modifies the variable, clicks on the "select all"
button, and then pastes the code into a Unix window (then presses
Ctrl-D to run the script).

I don't want a WYSIWYG editor, I don't even need the user to be able to
decide which text to make red. All I want is to be able to set a piece
of the textarea to be red in the firstplace.

Reading here & in various javascript script archives, it seems like I
need to do fancy IE/Mozilla-specific contentEditable stuff. Is there a
simpler way to handle it?

Thanks,

-Amir Karger

Jul 23 '05 #1
1 4963
fox


am***********@y ahoo.com wrote:
I want to do this:

<textarea>
perl
<font color="FF0000">
$thing_to_get=1 7;
</font>
More Perl code using $thing_to_get
</textarea>

But the above doesn't work, of course.

The idea is that I'm giving the users a bunch of text where they might
want to edit the red parts. Then I'll have a javascript button to
select all. A user modifies the variable, clicks on the "select all"
button, and then pastes the code into a Unix window (then presses
Ctrl-D to run the script).

I don't want a WYSIWYG editor, I don't even need the user to be able to
decide which text to make red. All I want is to be able to set a piece
of the textarea to be red in the firstplace.

Reading here & in various javascript script archives, it seems like I
need to do fancy IE/Mozilla-specific contentEditable stuff. Is there a
simpler way to handle it?


One way (among many similar) is to simply:

This is <span id=sectionname class=hilite onclick =
"changeText(thi s)">editable</span> content.

script support:

function
changeText(e)
{
if(s = prompt("change text to:", e.innerHTML))
e.innerHTML = s;

// you do not want to allow an empty string
// or the item "disappears " (nothing to click on)
}

use styles to dress up the hilited text any way you want...e.g.:

..hilite {
cursor: pointer;
color: red;
}

just make sure each editable section has a unique id attribute and this
will fit just about anywhere (except inside textareas and other form
elements)... will work with any server-side support.

BTW, this makes the resultant document printable [ use @print to change
hilite to color: black (or whatever)].

[tested ie and firefox/mozilla]

fox...
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2977
by: Manuel Reimer | last post by:
Hello, I want to add some text in front of an object. I want to use the ":before" tag for that. I've tried to do this like the following: object, embed + *:before { content:"test"; font-size: 1.2em; color: #000;
6
15428
by: TomT | last post by:
Hi, I've created a form that has a 3 fields. 2 textboxes (username & password) 1 TextArea (notes) I have linked this to an access DB. This is working well, the user enters thier Username & password, fills
8
41563
by: Orloff | last post by:
Hi, on most (all?) browsers, when you put the pointer on a <a href="..." title="popup text">this is a link</a> without clicking on the link, there is a popup caption with the "popup text". I would like to achieve the same with some text that is not a link. I realized that I could simply make it <a title="popup text">this is just some...
0
2694
by: Tony Johansson | last post by:
Hello! Below is a small program using the adaptor pattern. We have four classes these are: PegAdapter, RoundPeg, SquarePeg and a class TestPegs acting like a client In class PegAdapter has some text just above the class header saying "Its adapts a RoundPeg to a SquarePeg". In the class that acts as a client which isTestPegs
10
3867
by: Wayne Wengert | last post by:
Is there a way for ASP.NET/VB codebehind to get the contents of a plain old <textarea> element? I added an id='myname' to the <textarea> tag but VSNET complains that it is undefined? Wayne
7
1765
by: Ron | last post by:
Hello, I have 4 classes that use 4 DTS packages on 4 different tables. So I have Dim cls1 As New clsDTS1, cls2 As New clsDTS2 Dim cls3 As New clsDTS3, cls4 As New clsDTS4 Each class has a common property called DataPath cls1.DataPath = strPath
2
1564
by: mariomueller | last post by:
Hello everybody, I am looking for a method to get the text on the left and the right side if a user selects some text in a textarea. Regards Mario
5
1808
by: ad | last post by:
I want to show the background color of a row in a gridview to different color when the value of a column is greater than 100. How can I do?
3
2838
by: UJ | last post by:
Is there a way to have items in a drop down list where certain items are a different color? How about having items that are strikethrough? TIA - Jeff.
4
1215
by: barronmo | last post by:
I'm a beginner searching for an easy way to print the contents of a text control. So far I've come up with the following(difficulties): 1) using wxPython -convert to HTML and then print (I don't know anything about HTML) -use wx.Printout (Seems complicated; may be beyond my abilities) 2) create a text file and then print it out (can...
0
7459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5322
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
695
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.