Skip to main content

This blog will teach you how to conditionally change the background color of a select list in Oracle APEX.  We will be focusing on a select list and changing the background color, but this same logic can be applied to the styling of most page items.

Select List for Anonymous Level

For this example, let’s pretend we have an APEX application for receiving donations.  The form includes the option to choose an anonymous level because not all donors want to be recognized.

Background Color Change Dynamic Action

The anonymous level carries extra importance because selecting the wrong type of level could be disastrous.  In order to help prevent people from choosing incorrectly, we will have the background color change if the anonymous level is buy viagra bangalore online help writing history essay outline for a descriptive essay https://elkhartcivictheatre.org/proposal/my-nightmare-journey-essay/3/ cutting cialis tablets half https://preventinjury.pediatrics.iu.edu/highschool/conclusion-dissertation-philo-exemple/14/ seroquel stiffness essay on gnh le viagra a fait quoi cialis dziaanie cena get link creation myths essays viagra en grapefruit do i take cialis everyday go to link https://homemods.org/usc/personal-goal-essay/46/ source url essay compare and contrast two country dissertation deliverables meaning business plan grocery shop see url https://efm.sewanee.edu/faq/cost-proofread-dissertation/22/ https://servingourchildrendc.org/format/carpente-a-magna-bioprosthesis/28/ does viagra affect prostate cancer professional essay writing service freelance writer skills resume grade 9 essay on christmas carol https://cwstat.org/termpaper/quiz-on-essay-types/50/ source link click philippine news paper list essay on corruption for css 1 – Publication Internal Only or 2 – No Internal or External Publication.

To accomplish this, we need a Dynamic Action.

  1. Create a new Dynamic Action on the Anonymous Level select list
  2. Make the event a Change Event
  3. Add an Execute JavaScript Code True Action to the Dynamic Action
  4. Copy and paste the following code:

if ($v("P2_CODE_ANON") == 0){
$("#P2_CODE_ANON").css("background-color", "transparent");

}

else if ($v("P2_CODE_ANON") == 1){
$("#P2_CODE_ANON").css("background-color", "#F8F8BF");

}

else if ($v("P2_CODE_ANON") == 2){
$("#P2_CODE_ANON").css("background-color", "#EFD6CF");

}

Give it a Test and See the Results

When you select 1 – Publication Internal Only, the background color should be yellow.  Alternatively, when you select 2 – No Internal or External Publication, the background color should be red.

Requirements

  • Oracle APEX 5x+

Learn More

Disclaimer:
We do not take responsibility for any unintended or unwanted consequences in your instance of Oracle, Oracle APEX, or related products as a result of reading our blogs or following our guides. Though the information is fully tested and generally safe to use, our lawyers really have a thing against admitting potential wrongdoing. If it makes you feel any better, one time I convinced them that giving someone the middle finger is considered a term of endearment in France.