This discussion is archived
2 Replies Latest reply: Jan 22, 2013 7:01 PM by Howard (... in Training) RSS

greying out buttons based on condition

kp2000 Newbie
Currently Being Moderated
Hello
I am having a scenario where buttons will get activated only when 99% or 100% is reached.

I am having a page with NEXT button. user needs to enter some data and select percentage..
like, select option A for 33%,option B for 33% and option C for 33%..So total 99%..Till the total is atleast 99 the NEXT button should be greyed out.
Once it reaches 99% then NEXT is button can be used..

Any suggestions

thanks
kp
  • 1. Re: greying out buttons based on condition
    dominiquefortin Newbie
    Currently Being Moderated
    I would add:
    style="display: none;"
    to the button attributes and change it back to
    display: block;
    in javascript when the desired state is reached.
  • 2. Re: greying out buttons based on condition
    Howard (... in Training) Pro
    Currently Being Moderated
    How about a dynamic action based on the field(s) changing value. It would do some math and then set the button attribute to null (for not gray) or disable (for grayed). Here's some example code where I control the previous and next buttons depending whether data exists for the previous or next month.
    Begin
      SELECT CASE 
        WHEN EXISTS (SELECT 1 FROM NTWRK_PKT_CNT 
          WHERE (:F217_SYS_NIC_NM = (SYS_NM || '/' || NIC_NM)) 
            AND MEAS_DT < TO_DATE(:P3_MONTH,'Month YYYY') 
            AND ROWNUM = 1) 
        THEN '' 
        ELSE 'disabled="disabled"' 
        END 
        INTO :F217_PREV_BUTTON_CONTROL 
        FROM DUAL; 
      SELECT CASE 
        WHEN EXISTS (SELECT 1 FROM NTWRK_PKT_CNT 
          WHERE (:F217_SYS_NIC_NM = (SYS_NM || '/' || NIC_NM)) 
            AND MEAS_DT >= ADD_MONTHS(TO_DATE(:P3_MONTH,'Month YYYY'),1) 
            AND ROWNUM = 1) 
        THEN '' 
        ELSE 'disabled="disabled"' 
        END 
        INTO :F217_NEXT_BUTTON_CONTROL 
        FROM DUAL; 
    End; 
    For the PREVIOUS button, under Attributes, the Button Attribute is "F217_PREV_BUTTON_CONTROL". Or it's ":F217_PREV_BUTTON_CONTROL". I can't remember if I included the ":" or not.

    This has the virtue that the buttons are always visible -- they don't disappear causing other buttons to shift left / right.

    Regards,
    Howard

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points