Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / March 2007



Tip: Looking for answers? Try searching our database.

show icon on table insert

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
craiglaw98 - 20 Mar 2007 22:27 GMT
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?
Sojovi - 21 Mar 2007 03:27 GMT
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
craiglaw98 - 21 Mar 2007 05:13 GMT
ok thanks i have never used ajax, do you know where i can find some example code to do what i need
insuractive - 21 Mar 2007 16:59 GMT
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.
proxim00 - 21 Mar 2007 17:37 GMT
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.
craiglaw98 - 21 Mar 2007 20:18 GMT
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
Karthik Nataraj - 21 Mar 2007 20:33 GMT
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.
craiglaw98 - 23 Mar 2007 02:14 GMT
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?
Dan Bracuk - 23 Mar 2007 03:53 GMT
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.
craiglaw98 - 23 Mar 2007 13:46 GMT
ok thanks, this it what i have in my iframe currently, will i be able to hide
the icon and the flash movie(which is just a small sound) with the div tag?

<meta HTTP-EQUIV="REFRESH" content="60;
url=http://www.thesmsengine.com/SMS_Inbox_Note.cfm">

<CFQUERY  datasource="#application.ds#" Name="ShowInbox">
    SELECT *
    FROM SMS_Inbox
    where InboxClubID = '#session.ClubLogin#' AND InboxViewed = 1
</cfquery>

<CFQUERY datasource="#application.ds#" Name="ShowInboxbeep">
    SELECT *
    FROM SMS_Inbox
    where InboxClubID = '#session.ClubLogin#' AND InboxViewed = 1 AND Beep = 1
</cfquery>

<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>

<body>
<CFIF ShowInboxbeep.recordcount GT 0>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve
rsion=6,0,29,0" width="32" height="32">
  <param name="movie" value="beep.swf">
  <param name="quality" value="high">
  <embed src="beep.swf" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="32" height="32"></embed>
</object>

<CFQUERY datasource="#application.ds#" Name="ShowInbox23">
    UPDATE SMS_Inbox
    SET Beep = 0
    where InboxClubID = '#session.ClubLogin#'
</cfquery>
</CFIF>

</body>
</html>
craiglaw98 - 30 Mar 2007 00:10 GMT
ok it all works now, but i still get a page click sound when the iframe refreshes.

can i stop the sound somehow?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.