How to change color of a button

I’ve tried all of the following code and nothing works… what am I doing wrong?

There are 2 buttons (Bootstrap) on screen…
AppStudio v 6.2.3.1…

Function Button1_onclick()
'Dim VarRed
’Dim VarGreen
’Dim VarBlue
’VarRed = FuRandom(0,256)
'VarGreen = FuRandom(0,256)
'VarBlue = FuRandom(0,256)
'Button1.backgroundColor = RGB(VarRed,VarGreen,VarBlue) 'doesn’t work
Button1.backgroundColor = “Red” 'doesn’t work
End Function

Function FuRandom(VarLowRange,VarHighRange)
Dim x,VarLowRange,VarHighRange
If VarLowRange > VarHighRange Then
MsgBox(“Low range must be less than or equal to high range”,0,"")
Else
x = Rnd
FuRandom = Int((x * (VarHighRange + 1 - VarLowRange)) + VarLowRange)
End If
End Function

Function Button2_onclick()
'Button1.backgroundColor = “Red” 'and this doesn’t work
Button1.background = “Red” 'and this doesn’t work
End Function

SOLVED: Must add “style”… Button1.style.backgroundColor = “Red” works while Button1.backgroundColor = “Red” does NOT work.

Tom

changing the color of a button at runtime did not work for me too.

my workaround for setting buttons to green or red :

If …condition… Then ButtonOLR.appearance = “btn-success” Else ButtonOLR.appearance = “btn-danger” End If

appearance:
default=white
primary=dark blue
success=green
info=blue
warning=orange
danger=red
link=pale blue

Alexander… it’s solved… Button1.style.backgroundColor = “whatever”… just add the word “style”… Whatever is name of color, such as “Red” or “rgb(nnn,nnn,nnn)”

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.