manipulate character in a string -Rich text field

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
kousisAsked:
Who is Participating?
 
CRAKConnect With a Mentor Commented:
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
 
marilyngCommented:
Client or web?
0
 
kousisAuthor Commented:
it's on web
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
kousisAuthor Commented:
can anyone pls answer this question
0
 
marilyngCommented:
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
 
CRAKCommented:
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
 
marilyngCommented:
it's read-mode only!<< Yeah, I figured it would be only good in read-only using javascript.  
0
 
marilyngCommented:
But, SEE!! I knew you would know!!
0
 
CRAKCommented:
;-))
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
 
CRAKCommented:
kousis, did my post help in any way?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.