Solved

manipulate character in a string -Rich text field

Posted on 2006-06-12
12
344 Views
Last Modified: 2013-12-18
Hi

I want to change the color of the character in string stored in Rich text field.

For eg. "abcdefhj????sddf"

I want to change the color of the "?" mark to red color.
TIA
0
Comment
Question by:kousis
  • 4
  • 4
  • 2
12 Comments
 
LVL 18

Expert Comment

by:marilyng
ID: 16892106
Client or web?
0
 

Author Comment

by:kousis
ID: 16893041
it's on web
0
 

Author Comment

by:kousis
ID: 16900974
can anyone pls answer this question
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16904224
I sent a note off to CRAK to see if he would look at this for you.  I'm not at a Notes Computer or environement to set up a simulation.
0
 
LVL 13

Accepted Solution

by:
CRAK earned 100 total points
ID: 16905175
Wow.... Marilyn, why should this be special expertise of mine?
But up to a certain level you may be right (and thanks for the notification!):

I've created a test form with a RT field and filled it out:
abcdefg???hijkl
And just for fun, I colored "de" blue (rest was black).

In a web-copy of the form, I added following JS-code; right on the form where the RT field would be.
It was all marked as pass-though html, except the actual RT field, marked here as [RTFIELD] (yes, keep the single quotes around it!).

<Script language="javascript">
var rt='[RTFIELD]';
document.write(rt + '<br>')
var lastChar = '';
var currChar = '';
for (var i=0; i<rt.length; i++)
{
   currChar = rt.substr(i,1);
   if ((currChar=='?') && (lastChar!='?'))
   {
      document.write('<span style="color:red;">' + currChar);
   }
   else
   {
      if ((currChar!='?') && (lastChar=='?'))
      {
         document.write('</span>' + currChar);
      }
      else
      {
         document.write(currChar);
      }
   }
   lastChar = currChar;
}
</Script>

Perhaps here are easier ways (I'm curious!) or perhaps even better ones, as this one probably has a few limitations.
E.g. string length might may have limitations. Or the use of single or double quites inside the Rt field may cause trouble, but at least in the given example it'll work.

Do note that this won't do any good in editmode! it's read-mode only!

Feel free to redefine the <span> to refer to a stylesheet. A <font. definition wold be another option.

Enjoy!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

by:CRAK
ID: 16905259
Forgot to mention:
Do NOT mark the RT field as pass-through html: allow domino to do the html conversion first, for the best result!
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16908003
it's read-mode only!<< Yeah, I figured it would be only good in read-only using javascript.  
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16908005
But, SEE!! I knew you would know!!
0
 
LVL 13

Expert Comment

by:CRAK
ID: 16909305
;-))
I'm not too thrilled with the limitations though....
Since its processing domino's html output, it shouldn't matter if the RT field would contain e.g. a table with strings like that.
Domino, however, splits the html code for a table into several lines; something that JS isn't happy with (=unterminated strings)!
We should find a way to "@impode" RT's html output befor we allow JS to parse it....
I've already been thinking of involving @Abstract in the process, but that would make me lose other details from the RT field (e.g. those blue characters).
0
 
LVL 13

Expert Comment

by:CRAK
ID: 16949490
kousis, did my post help in any way?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now