A have a drop down list which is being populated by a database, certain options in the list have a different background colour according to whether they have been banned or not.
I would like to run a VB script which runs onChange which displays an alert if the user tries to select a user from the list which has a red background colour.
For Example:
Jim
Bob ----> Red Background (Highlighted Red)
Dave
Tom
then if the user tries to select Bob then it will bring up an alert and then focus the select back to NULL.
Sub TestSub()
frmCol = document.getElementById("frmNew").style.backgroundColor
if frmCol = "Red" Then
msgbox "This user is banned, please select another user!"
End If
End Sub
Hopefully that makes sense! Thank you for any help, very much appreciated. Ask if more details are needed!
Something like this should do what you want:
However, as @DanielCook said, just checking the actual name against a list of banned users would be a better approach, because the application logic is less shrouded that way: