12 Replies Latest reply: Aug 25, 2014 7:50 AM by Ziut RSS

    refreshing + javascript

    Ziut

      Hi

      This thread is follow on thread

      https://community.oracle.com/thread/3599765 (moderator decision):

       

      I would like to refresh item properties like font colour or backround.

      I try create javascript like this (prototype):

       

      <script type="text/javascript">

      function changeColour()

      {

        var item = document.getElementById    ("P2_CURRENT_VALUE")

         if(item.color = "green" ) {

           item.color = "red";   (???)

          }

          else {

           item.color = "green";

          }

      }

      </script>

      What I must  change in this definition and in aplication

      How to connect this script with item :P2_CURRENT_VALUE and fire it ?

       

      Regards

      Ziut

        • 1. Re: refreshing + javascript
          Denes Kubicek

          "I would like to refresh item properties like font colour or backround."

           

          You can create a dynamic action on change of an element and run some java script:

           

          $('#P2_CURRENT_VALUE').css('background-color','red');

           

          You can use conditions there as well and run it only if a condition is met. Javascript expression like:

           

          $('#P2_CURRENT_VALUE').css('background-color')=='rgb(0, 128, 0)'

           

          would check if the background color is green

           

          Denes Kubicek

          • 2. Re: refreshing + javascript
            fac586

            Ziut wrote:

             

            This thread is follow on thread

            https://community.oracle.com/thread/3599765 (moderator decision):

            1. I am not a moderator. I just didn't perceive any link between the original question and this one. This is because you didn't specifically reference the item name, and the item in the example isn't either of the colours mentioned.
            2. You still haven't provided any of the relevant information requested. APEX version, theme, browser/version, and background on the requirement are all necessary in order to answer questions relating to visual formatting and dynamic behaviour effectively.

            I would like to refresh item properties like font colour or backround.

            Why? What requirement is driving this?

            I try create javascript like this (prototype):

            "Prototype" has a specific technical meaning in JavaScript. Using the term in connection with JavaScript code outside of this strict sense is likely to be confusing. In this case, the term "pseudocode" as in your original thread is more appropriate. (Although syntax errors you have made in trying to write the method as JavaScript means that it is not an accurate pseudocode representation of your requirement.)

            <script type="text/javascript">

            function changeColour()

            {

              var item = document.getElementById    ("P2_CURRENT_VALUE")

               if(item.color = "green" ) {

                 item.color = "red";   (???)

                }

                else {

                 item.color = "green";

                }

            }

            </script>

            What I must  change in this definition and in aplication

            How to connect this script with item :P2_CURRENT_VALUE and fire it ?

            Start by explaining the requirement:

             

            • Why it is necessary to change the colour of this item?
            • When should this occur?
            • What should actually determine the item colour? The logic presented will simply result in the item changing from an unknown/unspecified original colour to green on the first invocation, then alternating between red and green on subsequent invocations. If the requirement is to convey some information according to the colour of the item this behaviour would appear to be arbitrary and potentially confusing given the perceived meanings attached to the colours specified in most cultures.
            • Is any information intended to be transmitted by the item colour clearly available through other channels to comply with accessibility requirements?
            • 3. Re: refreshing + javascript
              Ziut

              Thanks Denes

              ...but I would like to change with "if" statement.

              scenario:

              1. value of P2_CURRRENT_VALUE is changed every eg 5 sec with dynamic action

              2. when this value has changed I would like to change colour: green, red, green, red -  every 5 sec when value is changed

               

              You may see app:

               

              https://apex.oracle.com/pls/apex/f?p=257

               

              Ziut

              • 4. Re: refreshing + javascript
                fac586

                Ziut wrote:

                 

                2. when this value has changed I would like to change colour: green, red, green, red -  every 5 sec when value is changed

                Why? What purpose does this colour change serve?

                • 5. Re: refreshing + javascript
                  Ziut

                  it is not important - why?

                  for me - important is - how.

                  Ziut

                  • 6. Re: refreshing + javascript
                    Denes Kubicek

                    if ($('#P2_CURRENT_VALUE').css('background-color')=='rgb(255, 0, 0)')

                    {$('#P2_CURRENT_VALUE').css('background-color', 'green')}

                    else

                    {$('#P2_CURRENT_VALUE').css('background-color', 'red')}

                     

                    Denes Kubicek

                    • 7. Re: refreshing + javascript
                      Ziut

                      Thanks Denes

                       

                      Two questions for you:

                       

                      1. The same but with colour of text?  I don't find it.

                      2. Is it possible to change colour a field in report when it is changed.

                      Ziut

                      • 8. Re: refreshing + javascript
                        fac586

                        Ziut wrote:

                         

                        it is not important - why?

                        Since a significant proportion of the population are unable to distinguish between red and green, it is critically important to consider the implications of transmitting information using these colours.

                         

                        If no information is being conveyed by alternating these colours, then doing it at all appears to be pointless. If the colour change is intended to be informative then provision must be made to transmit the intended information using multiple channels, not just colour. Failure to do so has implications for the accessibility of the application and may result in liability for non-compliance with accessibility legislation.

                        • 9. Re: refreshing + javascript
                          Denes Kubicek

                          $('#P2_CURRENT_VALUE').css('color', 'green');

                           

                           

                          2. Is it possible to change colour a field in report when it is changed.

                           

                          You never change values in a report but you display. Change how?

                           

                          Denes Kubicek

                          • 10. Re: refreshing + javascript
                            Ziut

                            Hi Denes

                             

                            If you look in my app:

                            https://apex.oracle.com/pls/apex/f?p=257

                             

                            you can see Refreshing Region and column Frequency. This report is created as sql query from one table (drawing_table).

                            DML (update drawing table set frequency = frequency + 1 where value = ...) is running every eg 5 sec (across a job). In one moment only one row is updating.

                             

                            I would like to change colour in this row.

                            Scenario:

                            1.  update drawing table

                                set frequency = frequency + 1 where value = 2;

                            2. change frequency field for value 2 - eg. red

                             

                            3.  update drawing table

                                set frequency = frequency + 1 where value = 5;   

                            4. change frequency field for value 2 - no colour

                            5. change frequency field for value 3 - red

                             

                            Or other scenario:

                             

                            previous field has red and current green.

                             

                            I think I must do something in table. Maybe work_column (Yes and No) and using this selector during generating report?

                            What do you think?

                            Regards

                            Ziut

                            • 11. Re: Re: refreshing + javascript
                              Tom Petrus

                              Pretty interesting to see you ignore fac586's requests for more info. Seems like he was right right from the start isn't it? Here you are, replying to your supposedly correctly answered thread, saying that what was provided doesn't really do what you want after all. So then you feed us just a bit more info. Why couldn't you have provided your specifications from the get-go? We're -still- not sure as to what and why has to happen?

                              I inspect your page source and can derive from there, but that shouldn't really be up to me: you should explain clearly:

                              - What do you have

                              - What is wrong with it

                              - What should happen, and perhaps why, so that we may perhaps offer a better way of achieving it?

                              Right now you have a refresh of a region, which triggers a plsql code execution, which sets an item, which in turn fires another da to set the color of the item alternating between red and green for no apparent reason.

                              What has to happen when the report is refreshed? What do your scenario's even mean? (And I'm just repeating fac586's questions)

                              Start by explaining the requirement:

                              • Why it is necessary to change the colour of this item?
                              • When should this occur?
                              • What should actually determine the item colour? The logic presented will simply result in the item changing from an unknown/unspecified original colour to green on the first invocation, then alternating between red and green on subsequent invocations. If the requirement is to convey some information according to the colour of the item this behaviour would appear to be arbitrary and potentially confusing given the perceived meanings attached to the colours specified in most cultures.
                              • Is any information intended to be transmitted by the item colour clearly available through other channels to comply with accessibility requirements?

                              I'm sure that even at this point you have Denes guessing as to what you need.

                              • 12. Re: refreshing + javascript
                                Ziut

                                Tom

                                it's very simple.

                                I'm interested in solving apex problems because I would like to know it better.

                                It's not business problem, only technological and  (hmm...) scientific.

                                You may use it in eg systems providing public services and many others.

                                 

                                User has  my  working application on the screen and has been monitoring results continuously.

                                Colour is not important. it may be magenta and blue. it may be font or style (bold, italic) etc. I would like to know how to do it.

                                 

                                Tom and fac586 (I don't know his name): Help me please if you want find this solution because as yet only words, words, words.

                                Regards

                                Ziut