10 Replies Latest reply on Mar 29, 2007 4:10 PM by craig_mac

    show icon on table insert

    craig_mac Level 1
      hi i would like to have a notice on my webpage if a new record gets inserted to a table in my database

      ie if a new record is entered a small icon appears on the page, can this be done without having to refresh the page?
        • 1. Re: show icon on table insert
          Sojovi Level 1
          You can do it with AJAX, sending a query to the DB every X seconds or minutes and having a variable with the last record ID in the table. If after querying the DB, the record ID is higher, then you have new records inserted.

          Regards
          • 2. Re: show icon on table insert
            craig_mac Level 1
            ok thanks i have never used ajax, do you know where i can find some example code to do what i need
            • 3. Re: show icon on table insert
              insuractive Level 3
              A quick search for Coldfusion Ajax example in google turned up a plethora of choices. This one looked appropriate:

              http://www.quackit.com/ajax/ajax_tutorial.cfm

              In addition to straight up ajax, there are a number of framewords that make creating ajax calls a little more user friendly. Popular choices on this forum are Adobe's Spry framework and CFAjax.
              • 4. Re: show icon on table insert
                proxim00
                One thing to keep in mind is that AJAX is useing javascript so if your not good with JS then you may need to read up some before jumping into it.
                • 5. Re: show icon on table insert
                  craig_mac Level 1
                  ok thanks i have had i look, i understand the coldfusion code but i am not sure about the js file.

                  do you know the exact code i would need in the js file to do what i need?


                  many thanks
                  • 6. Re: show icon on table insert
                    Karthik_Nataraj Level 1
                    There is another option of using SOAP & Dynamic HTML. You have to write a component in VB that will retrive the data from your database and return back. The method in the VB has to be exposed and SOAP WSDL configured. You can use MS SOAP toolkit to built the WSDL for your component if you are not used to it.

                    In your web page, write javascript that calls a function say every minute. This javascript function has to use MSXML objects and submit a request as SOAP call. You will get the response and based on the response, dynamically manupulate your web page without refreshing.

                    If you are not familiar with all these write a <IFRAME> with no border in your page and this frame content will refresh every minute to get the content what you want. Really the user will not know you are refreshing the page as the iframe will be small and only a part of your page.
                    • 7. Re: show icon on table insert
                      craig_mac Level 1
                      ok thanks i have tried the iframe way, but when the page refreshes i get a page click sound

                      so every 60 secs i get a click sound

                      can i get rid of this?
                      • 8. Re: show icon on table insert
                        Dan Bracuk Level 5
                        You can do it without AJAX. You have to run some code anyway to insert the record, so put the icon up after the insert.

                        If you are doing the insert in an iframe or popup, put the icon on your main page inside a div tag and make it invisible. Use inner html to make that tag visible after you run your insert.
                        • 10. show icon on table insert
                          craig_mac Level 1
                          ok i found some code to stop the click sound, but when my page refreshes now i get a white page.

                          i am tring to code if query recordcount = 0 the show background red else show background image, so i am not sure why i am getting a white page?

                          <head>
                          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                          <script type="text/javascript" src="silent_refresh.js"></script>






                          <CFIF ShowInbox.recordcount GT 0>
                          <style type="text/css">
                          <!--
                          body {
                          background-image: url(images/icon2.gif);
                          }
                          -->
                          </style>
                          <cfelse>
                          <style type="text/css">
                          <!--
                          body {
                          background-color: #BB2020;

                          }
                          -->
                          </style>
                          </CFIF>
                          </head>