11 Replies Latest reply on Aug 3, 2006 9:32 PM by ranger

    array and iframe

    ranger Level 1
      i have a automatically refreshing page within an iframe (iframe page) that needs to loop thru rows of a table in sequence so that new a new picture and text is displayed on each refresh.

      rather than doing a query on each refresh (every 5 secs.) i set up the query and array on the page that contains the iframe (main page).

      problem is that the iframe page cannot find the array....

      this "test display" is from query and query loop to set up array... "main page"

      picID: 1, picfile: rocket.jpg, piccmts: rocket stage
      picID: 2, picfile: pell.jpg, piccmts: Safety - Pell - Advanced
      picID: 3, picfile: service.jpg, piccmts: Service with a smile - modus opperandi.,
      picID: 4, picfile: rope.jpg, piccmts: Rope in Action,
      picID: 5, picfile: marine.jpg, piccmts: 500 lbs - Marine Applications,
      picID: 6, picfile: recovery.jpg, piccmts: Recovery in Action,
      picID: 7, picfile: adj.jpg, piccmts: Adf in Action,

      would then output data in iframe page based on loop to display row as in picID = 5

      #picarry[5][2]# - #picarry[5][3]#

      "marine.jpg" and "500 lbs - Marine Applications"

      since iframe is in (sub to) "Main Page"... why can't it find array... is there a workaround. do not want to ping db every refresh of iframe.

      if this won't work, any other solution would be greatly appreciated

      tnx in advance

        • 1. Re: array and iframe
          Dan Bracuk Level 5
          Make the query a session variable.
          • 2. Re: array and iframe
            ranger Level 1
            actually cacheing query seems a lot less intensive (which i did) but was just asking why an iframe cannot find an array in "top" page....
            • 3. Re: array and iframe
              Dan Bracuk Level 5
              If you are running the query in the parent page and refreshing the content of the iframe, caching the query achieves nothing.

              To access variables in the parent page scope the variable with parent. At least I think that's how you do it, I always use session variables because it is so much simpler.
              • 4. Re: array and iframe
                - There is no "parent" scope.

                - Think of an iframe as any other page that is in the same session.

                - Only to the client is the iframe a sub of the parent. ColdFusion knows nothing about this relationship.

                - If this data is consistent across the entire application then I recommend caching the entire query or saving it to application scope. You can access the necessary info with array notation when needed #picQuery[rowNumber]["columnName"]# (preceed with "application." if in that scope), or if you need to grab a row from the query based on something other than the rowNumber use a query of a query (dbtype="query").

                - If this is user specific data and accessed often by each users then you can throw it into session scope. If this isn't going to be hit often per user then it's not worth worrying much about.

                Let me know if you have any questions.
                • 5. Re: array and iframe
                  truewrestler Level 1
                  Just to clarify so there is no confusion.

                  The main page will output the iframe tag with the src attribute pointing to another cfm page.

                  The CF page called in the iframe will make db call with the cache attributes and do query of queries as necessary.

                  The setting of the data in application or session can occur anywhere and then you'll need to scope the variable names when accessing them in the cfm page appearing with-in the iframe.

                  FYI. Each time a query's sql changes, usually with-in the where clause, that is a different cached query. ColdFusion servers have a limit on the number of cached queries, set in the CF Administrator with I believe less than 10 by default. You should reduce the number of cached queries, so they don't just overwrite each other, by grabbing a lot of data in a query that is to be cached instead of grabbing individual rows.

                  There are also ways to accomplish what you are doing in javascript but lets just stick to CFML for now.
                  • 6. Re: array and iframe
                    truewrestler Level 1
                    On second thought... if you just want to change an image on your site every 5 seconds that's probably a good candidate for javascript. Reply with a more thorough description of what you would like to do.
                    • 7. Re: array and iframe
                      ranger Level 1
                      first, thanks all the responses...

                      the home page contains iframe and not only a pic but descriptive text is displayed in iframe file... site owner can change/add to list of pics/text that display via backend tools.

                      i have cached query on iframe page which creates array. then just pull data from array with loopcount selecting row. the pics/text loops (refreshes page) thru list 3 times, then stops on first pic/text.

                      array is rebuilt each refresh (query cached) but seems to work very fast... 10ms

                      home page is only page that uses this action but same all visitors so don't know if app scope would lighten server load...?
                      • 8. array and iframe
                        truewrestler Level 1
                        You can go the way I explained earlier but an alternative is to output the array as javascript code for an array (or use something like CFJSON to encode). Then on your page have code to use the array to make changes on the page every 5 seconds. This way you have one request for the info when the user opens the page and then the changes run on the client instead of extra requests back to the server.

                        I sounds like a cached query is the way to go since items could be added and removed often. If the data is in the application scope you'll need to write code to check if it needs to be reloaded so might defeat the purpose a bit.
                        • 9. Re: array and iframe
                          ranger Level 1

                          tnx again.... seems except for query which is always the same (barring owner additions) and is cached (probably will set for days with owner tools refresh), everything else must be recreated by visits - the array, etc.

                          as this seems to happen very fast and puts little stress on server, dont see advantage of js. also as visitors may be govt with very high security settings or industrial types running dated software, get a little nervous with js.

                          i do not use cookies or sessions... for client tracking use uID (token?) all links .works very well both for client side security issues and order tracking. more work in codeing but very fast in operation and no worries of timing-out or momentary blips.
                          • 10. Re: array and iframe
                            truewrestler Level 1
                            How are you going to change the iframe to a new page without javascript? :-)

                            You mentionned the array... a quick FYI, if you are just using the array as a way to pick out individual records then you can use array notation to access query object records directly: queryName[rowNumber]["columnName"]

                            Anyways, good luck with everything.
                            • 11. Re: array and iframe
                              ranger Level 1
                              you asked....