Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 18 APR 2012 07:25:34PM Richard Bright wrote:

I am wanting to change the background color of a editcell - to green or red - flagging the data state, as a result of data entered.

So I have qualified the cell with a CHANGED event, and trap that sucessfully, retrieve the cell vale and now want to udpdate the cell style acording to its status so … Here is the rough code BUT help does not explain WHAT color setting values are allowed -

* evaluate what the user entered

Pass = O4WGetValue("pwd")

Passc = O4WGetValue("pwdc")

If Pass = Passc Then

  • This is good - set style - bColor to green
 bcolour = 'green'
  O4WUPDATE("pwdc", '', O4WCOLORSTYLE('', bcolor, '', ''))

End Else

  • Bad - style red

Is there a chance we can get some expansion on the documentation?


At 19 APR 2012 10:09AM bshumsky wrote:

I am wanting to change the background color of a editcell - to green or red - flagging the data state, as a result of data entered.

So I have qualified the cell with a CHANGED event, and trap that sucessfully, retrieve the cell vale and now want to udpdate the cell style acording to its status so … Here is the rough code BUT help does not explain WHAT color setting values are allowed -

* evaluate what the user entered

Pass = O4WGetValue("pwd")

Passc = O4WGetValue("pwdc")

If Pass = Passc Then

  • This is good - set style - bColor to green
 bcolour = 'green'
  O4WUPDATE("pwdc", '', O4WCOLORSTYLE('', bcolor, '', ''))

End Else

  • Bad - style red

Is there a chance we can get some expansion on the documentation?

Hi, Richard. The available color settings are those that are supported by the internet. Unfortunately, it is not convenient to document the entire internet, unless you're Google. So you can look up the various color choices by Googling (or using your preferred search engine) with the phrase (for example) "HTML COLOR CODES" (which will return some web sites that even let you dynamically pick a color and will give you the hex code, which you would then enter into your code like this: bcolour = '#00FF00'), or 'HTML COLOR NAMES'.

Hope that helps,

- Bryan Shumsky

Revelation Software, Inc.


At 19 APR 2012 04:49PM Richard Bright wrote:

Bryan,

Thanks for the explanation.

It would have been helpful if the help cocument defined WHAT the varaiables where ie the 6 digit rgb Html Color Codes eg red = #FF0000; green = #00FF00 ; blue = #0000FF or css colors which may be available via css inserts and gave an example.

However my problem seems more fundamental, or at least may be multiple issues. I have tried a number of variations in code, bottom line is that O4WUpdate() doesent elicit the expected behaviour -

Case EVENT _EQC "CHANGED"

Begin case
  Case CtlEntId _eqc "pwdc"
      O4WResponse()
      debug
  • evaluate what the user entered
     Pass = O4WGetValue("pwd")
     Passc = O4WGetValue("pwdc")
  • Bad - style red
  • bcolor = '#FF0000'
    bcolor = \FF0000\
    ColorRed = O4WColorStyle('red',bcolor, '', '')
    If Pass = Passc Then
  • This is good - style green
       bcolor = \00FF00\
      O4WUPDATE("pwdc", '',O4WColorStyle('green',bcolor, '', '') )
 End Else
  • Bad - style red
     bcolor = \FF0000\
     O4WUPDATE('pwd', '',O4WColorStyle('red',bcolor, '', '') )
     O4WUPDATE('pwdc',Passc, ColorRed)
End

End Case

Regards Richard


At 19 APR 2012 05:08PM bshumsky wrote:

Bryan,

Thanks for the explanation.

It would have been helpful if the help cocument defined WHAT the varaiables where ie the 6 digit rgb Html Color Codes eg red = #FF0000; green = #00FF00 ; blue = #0000FF or css colors which may be available via css inserts and gave an example.

However my problem seems more fundamental, or at least may be multiple issues. I have tried a number of variations in code, bottom line is that O4WUpdate() doesent elicit the expected behaviour -

Case EVENT _EQC "CHANGED"

Begin case
  Case CtlEntId _eqc "pwdc"
      O4WResponse()
      debug
  • evaluate what the user entered
     Pass = O4WGetValue("pwd")
     Passc = O4WGetValue("pwdc")
  • Bad - style red
  • bcolor = '#FF0000'
    bcolor = \FF0000\
    ColorRed = O4WColorStyle('red',bcolor, '', '')
    If Pass = Passc Then
  • This is good - style green
       bcolor = \00FF00\
      O4WUPDATE("pwdc", '',O4WColorStyle('green',bcolor, '', '') )
 End Else
  • Bad - style red
     bcolor = \FF0000\
     O4WUPDATE('pwd', '',O4WColorStyle('red',bcolor, '', '') )
     O4WUPDATE('pwdc',Passc, ColorRed)
End

End Case

Regards Richard

Hi, Richard. Sorry, you didn't quite understand me - you do NOT put the hex values into the O4W code. You put the LITERAL STRING of the hex values, including the "#", into the O4W code. So your code should read:

    bcolor = "#FF0000"
    ColorRed = O4WColorStyle('red',bcolor, '', '')
    If Pass = Passc Then
  • This is good - style green
       bcolor = "#00FF00"
      O4WUPDATE("pwdc", '',O4WColorStyle('green',bcolor, '', '') )
   End Else
  • Bad - style red
      bcolor = "#FF0000"
      O4WUPDATE('pwd', '',O4WColorStyle('red',bcolor, '', '') )
      O4WUPDATE('pwdc',Passc, ColorRed)
  End

But if you just want to use the pre-defined HTML colors for 'red' and 'green', then you don't even need to pass in the hex values - you can use the LITERAL STRING of the color names ("red" or "green").

In addition, you're not calling the O4WUpdate properly. You MUST provide, in the 3rd parameter, an O4WResponseOptions() value to indicate _what_ part of the "target" is getting updated - the text, or the style, or both.

Another note - When using the O4W "styles", you don't _need_ to name them if you're not going to reuse them; similarly, if you _do_ name them, then you don't need to put the definition itself into your calls.

So here are some alternative ways in which we could implement your code:

Alternative 1: use the O4W colorstyle to create the color once (using the hex values), and then apply it:

    O4WColorStyle('red', "#FF0000")
    O4WColorStyle('green', "#00FF00")
    If Pass = Passc Then
  • This is good - style green
      O4WUPDATE("pwdc", '', O4WResponseOptions('','1'):"green")
   End Else
  • Bad - style red
     O4WUPDATE('pwd', '', O4WResponseOptions("","1"):"red" )
      O4WUPDATE('pwdc',Passc,  O4WResponseOptions("1","1"):"red")
  End

Alternative 2: use the O4W colorstyle to create the color style "dynamically" (using the hex values):

    If Pass = Passc Then
  • This is good - style green
      O4WUPDATE("pwdc", '', O4WResponseOptions('','1'):O4WColorStyle('', "#00FF00"))
   End Else
  • Bad - style red
     O4WUPDATE('pwd', '', O4WResponseOptions("","1"):O4WColorStyle('', "#FF0000") )
      O4WUPDATE('pwdc',Passc,  O4WResponseOptions("1","1"):O4WColorStyle('', "#FF0000"))
  End

Alternative 3: use the O4W colorstyle to create the color once (using the color names), and then apply it:

    O4WColorStyle('red', "red")
    O4WColorStyle('green', "green")
    If Pass = Passc Then
  • This is good - style green
      O4WUPDATE("pwdc", '', O4WResponseOptions('','1'):"green")
   End Else
  • Bad - style red
     O4WUPDATE('pwd', '', O4WResponseOptions("","1"):"red" )
      O4WUPDATE('pwdc',Passc,  O4WResponseOptions("1","1"):"red")
  End

A final point - I don't know what "pwd" and "pwdc" are, but I'm guessing they're textboxes or password textboxes. You may find that, depending on the browser, the background color on the textbox or password textbox _can't_ be set (or rather, it can be set, but it won't be seen). You might want to try to set the _foreground_ color (the text color itself) rather than the background color, and see if that changes anything for you. Remember, to set the foreground color, that's the 3rd parameter of the O4WColorStyle (the background color is the 2nd parameter).

Hope that helps,

- Bryan Shumsky

Revelation Software, Inc.


At 19 APR 2012 06:47PM Richard Bright wrote:

Great - thanks Bryan, particularly for detailed explanation / correction of my code.

It was the O4WResponseOptions() that I was missing - and why I went round and round in circles trying variations of color name / hex etc with no luck.

Am now out of the parking lot - heading for freeway as the O4WREsponseOptions explains why I couldnt get other stuff to play with me.

And the caveat on colourising O4WEditbox held true - no change in the Chrome browser, either fore or background. No problem - just being awear of that - in my schema not essential. I had two lines - the password and a check entry (standard Editbox). If text matched, blank out the plain line, if not colour red.

Thanks again, now to prepare next question….

Richard


At 04 APR 2021 08:49PM Robert Lee wrote:

Hi Bryan

This was a helpful thread. However, it seems that O4WResponseOptions only *adds* to the existing list of classes, rather than *replacing* them. So the above seems to work fine first time - "pwdc' might end up with class="red". But the second time through it seems that "pwdc" ends up with class="red green", which is undesirable.

I have a situation similar to this but where I need to toggle the classes… Any suggestions?

Cheers

Robert


At 05 APR 2021 08:15AM bshumsky wrote:

Hi Bryan

This was a helpful thread. However, it seems that O4WResponseOptions only *adds* to the existing list of classes, rather than *replacing* them. So the above seems to work fine first time - "pwdc' might end up with class="red". But the second time through it seems that "pwdc" ends up with class="red green", which is undesirable.

I have a situation similar to this but where I need to toggle the classes… Any suggestions?

Cheers

Robert

Hi, Robert. O4WQualifyEvent has some methods that will help you (though they may only be in OI 10, so they may not help _everyone_) named "removeclass", "addclass", and "toggleclass", if you're looking to have this happen as a result of another element being clicked - is that the scenario? Or did you just want this to happen programmatically, and not in response to a click event?

If you just wanted to have your code remove a class (but not in response to another element like a button getting clicked), then the easiest thing to do is to make an O4WPlugin call. Let's say there's an element with the ID of MYELEMENT, which has the class CLASS1. If you want to remove that class, you can add the following code:

O4WPlugin("MYELEMENT", "removeClass", '"CLASS1"')

(note the capitalization - the element ID has to match _exactly_, and the "plugin name" we're calling has to be specified in that exact way). Also especially note that the class name (in our case, CLASS1) has to be passed in quotes, so there's actually a single quote, then the double quote, then the class name (EXACTLY as it is currently defined), then the double quote, then the closing single quote.

You can do the same "trick" to add a class (using the "addClass" method instead of "removeClass") and toggle a class (using "toggleClass").

Hope that helps!

- Bryan Shumsky

Revelation Software, Inc.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/a9aedc7100043069eb147f400.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1