Forum Discussion

MichaelTamoush's avatar
MichaelTamoush
Qrew Captain
3 years ago

Rich Text Syntax

This is something simple, but I still feel like I'm not doing this in the cleanest way. Below is an example of some basic red text in italics.

"<span style='font-size:12px;color:#e61515'><i>words are going here</i></span>"

I simply want to be able to make the style a var text, so that in complicated fields I can clean up my coding. I found something that works, but I'm not convinced it is the cleanest method. Still feels like too many single and double quotes. Anyone use a nicer/cleaner syntax?

var text Style = font-size:12px;color:#e61515;

"<span style='" & $Style & "'><i>words are going here</b></span>"

For example, anyone have clean syntax for changing the color of text in the middle of a sentence and then changing it back? I can make it work, but I feel like my version is too clunky and long.

------------------------------
Michael Tamoush
------------------------------

4 Replies

  • PaulPeterson1's avatar
    PaulPeterson1
    Qrew Assistant Captain
    You're very close.  Try:

    var text Style = "\"font-size:12px;color:#e61515\"";

    I've wanted to set my styles as app variables.  Sharon Faust aka Quickbase Junkie has a video on doing just that, but I haven't made time to make those changes yet

    ------------------------------
    Paul Peterson
    ------------------------------
  • If you're only intending to use the style for one specific phrase, I'd go with something like this:
    var text words = "<span style='font-size:12px;color:#e61515'><i>words are going here</i></span>";
    "word word word " & $words & " word word word"

    If you want to repeat the styling, try this:
    var text startTags = "<span style='font-size:12px;color:#e61515'><i>";
    var text endTags = "</i></span>";
    "word word word " & $startTags & " words are going here " & $endTags & " word word " & $startTags & "yet more words" & $endTags & " word."

    ------------------------------
    Ahuva Brown
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      Thanks! Both good ideas. I like the starttag endtag variables, that is clever. Ill also check out the video by @Quick Base Junkie.


      ------------------------------
      Michael Tamoush
      ------------------------------
      • QuickBaseJunkie's avatar
        QuickBaseJunkie
        Qrew Captain

        Thanks for the mention @Paul Peterson!

        Michael, I know you're familiar with my videos/site, but for anyone else looking for the App Variable video, I've added it here.

        @Ahuva Brown had a great suggestion with the $startTags $endTags. The only thing I'd add is you can include the italic or bold in the style element to simplify the tags (even though it does add more 'text' overall).

        style="font-size:12px; color:#e61515; font-style:italic; font-weight:bold"

        *Note: bolding doesn't appear to make much of an impact on the default QB font, so you may also need to add a different font to your style element (font-family: Arial,sans-serif)

        And there's lots more over on the Quick Base Junkie Blog regarding HTML and other Quickbase topics.


        ​​​

        ------------------------------
        Quick Base Junkie
        ------------------------------