9 Replies Latest reply on Sep 14, 2018 3:07 PM by Flammifer

    onchange for apex_item.text

    Flammifer

      I have apex_item.text which is used to input percentage. I need to limit this input so it can't be > 100.
      Can this be achieved with onchange event on this item, jQuery Selector for input[name="fnn"], and JS code to check number is not >100? Any other way?

       

      Thanks.

        • 1. Re: onchange for apex_item.text
          Joe Upshaw

          You could just add in the HTML min and max attributes, e.g. <input type="number" name="YOUR_INPUT_NAME_HERE" min="1" max="100">

          • 2. Re: onchange for apex_item.text
            Flammifer

            Hi, where can I add it? Can it go into one of apex_item.text() parameters?

            • 3. Re: onchange for apex_item.text
              MattMcGeek

              You can add those under attributes in this function:

               

              apex_item.text(p_idx => '', p_value => '', p_size => , p_maxLength => , p_attributes => 'min="1" max="100"', p_item_id => '', p_item_label => '')

              1 person found this helpful
              • 4. Re: onchange for apex_item.text
                Joe Upshaw

                You're already creating the item via a call to APEX_ITEM.TEXT. One of the arguments into this is function is p_attributes. You can stick anything you want there:

                 

                For example:

                 

                       APEX_ITEM.TEXT( p_idx         => 6,

                                       p_value       => TO_CHAR( HAIRCUT_NON_INVENTORY, :DEFAULT_NUMBER_FORMAT ),

                                       p_attributes  => 'class="riskEditableControl riskCurrencyInput nullCheck numericOnlyCheck netCapitalComponent" downloadableHeader="HAIRCUT_NON_INVENTORY"',

                                       p_size        => :CURRENCY_INPUT_SIZE,

                                       p_maxLength   => :CURRENCY_INPUT_MAX_LENGTH,

                                       p_item_id     => 'haircutNonInventory_ID' || LPad( TO_CHAR( ROWNUM ), 5, '0' ) ) AS EDIT_HAIRCUT_NON_INVENTORY,

                 

                So, you could have:

                 

                       APEX_ITEM.TEXT( p_idx         => 6,

                                       p_value       => TO_CHAR( HAIRCUT_NON_INVENTORY, :DEFAULT_NUMBER_FORMAT ),

                                       p_attributes  => 'min="1" max="100"',

                                       p_size        => :CURRENCY_INPUT_SIZE,

                                       p_maxLength   => :CURRENCY_INPUT_MAX_LENGTH,

                                       p_item_id     => 'haircutNonInventory_ID' || LPad( TO_CHAR( ROWNUM ), 5, '0' ) ) AS EDIT_HAIRCUT_NON_INVENTORY,

                • 5. Re: onchange for apex_item.text
                  Flammifer

                  Can't get it to work still, this is the context:

                   

                   

                  CASE

                          WHEN upper(:P62_BILLING_METHOD) = 'NORMAL' and upper(:P62_BILLING_STATUS) in ('WORKING') THEN

                              apex_item.text(3,cumulative_percentage,10,10,'class="cum_pct arrow_traversal" min="1" max="100"  style="text-align:right;" data-field_type="cum_pct" data-seq_id="'||seq_id||'" autocomplete="off"')

                          ELSE

                              to_char(cumulative_percentage,:AMOUNTFORMAT) || apex_item.hidden(5,cumulative_percentage,'class="cum_pct"')

                          END cumulative_percentage

                   

                   

                  I'm not sure if I'm missing that input type is "number"

                  • 6. Re: onchange for apex_item.text
                    Flammifer

                    If I do:

                     

                    apex_item.text(3, to_char(ac.cumulative_percentage, :DEFAULT_NUMBER_FORMAT),'class="cum_pct arrow_traversal" min="1" max="100" style="text-align:right;" data-field_type="cum_pct" data-seq_id="'||ac.seq_id||'" autocomplete="off"',

                                               :CURRENCY_INPUT_SIZE, :CURRENCY_INPUT_MAX_LENGTH )

                     

                    then the error is Invalid Number ORA-01722

                    • 7. Re: onchange for apex_item.text
                      Flammifer

                      I mean I would like to restrict in real-time. Should I use JS for that? And then set as onchange="function();"

                       

                       

                       

                       

                      • 8. Re: onchange for apex_item.text
                        Joe Upshaw

                        Flammifer,

                         

                        That was just an example and it had a lot of parameters that would be set in my system but, wouldn't exist in yours, e.g. DEFAULT_NUMBER_FORMAT.

                        Here is a simplified example with placeholders for you to fill in:

                         

                        • 9. Re: onchange for apex_item.text
                          Flammifer

                          I solved it by calling JS function onchange, which reverts number to 100 if user types in greater than 100, and restricted to 3 digits/chars.

                           

                          Thanks for your replies, I think if I get it correctly, min and max will work upon Submit, but onchange event works better in this case.