Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
change color of unread messages
Old 02-05-2012, 02:39 AM change color of unread messages
Super Talker

Posts: 112
Name: Joan
Trades: 0
Hello,

I have set up a showhint function in JS to show data from a table in the database on mouseover, the content of this field is updated periodically and what im trying to do is the first time the user pass his mouse over the link the text shows in red and the second time he does it the text shows in black, like in some way let user know that the first time the text is display in red is because he has unread text and after that the text shows in black letting him know he has no unread content.. this is the code but im not very sure if this is even possible and if it is a php topic or JS topic? thanks for your help
PHP Code:

$case 
$data['case_no'];

global 
$conn;
$sql "SELECT `notes` FROM `counselor_notes` WHERE `case_no` = '".$case."'";
$rs db_query($sql,$conn);
$row db_fetch_array($rs);


$msg "Notes: "$row['notes'];

    
$fvalue "<a href=\"counselor_notes_edit.php?editid1=".$case."\" onmouseover=\"showhint('".$msg."', this, event, '500px')\" target=_blank><font color=\"black\">".$value." </font></a>";


$value $fvalue
stivens is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-05-2012, 11:22 AM Re: change color of unread messages
miki86's Avatar
Extreme Talker

Posts: 239
Location: print_r($serbia);
Trades: 0
Quote:
Originally Posted by stivens View Post
im not very sure if this is even possible and if it is a php topic or JS topic?
A little bit of both.
It depends on how you want to do it.

You need to have that note state stored somewhere so you can compare it.
It can be done with cookies, session or mysql.
Choose what best suits you, i would do it with cookies.

After you store that note ID for example, and it's state, you can write a javascript and change it's state once the user has view it.

Then you can easily change that note css class.
miki86 is offline
Reply With Quote
View Public Profile
 
Old 02-06-2012, 03:20 PM Re: change color of unread messages
Super Talker

Posts: 112
Name: Joan
Trades: 0
Thanks, i will try that
stivens is offline
Reply With Quote
View Public Profile
 
Old 02-06-2012, 09:23 PM Re: change color of unread messages
Super Talker

Posts: 112
Name: Joan
Trades: 0
can you give me an example of this??

the part of changing the state when the user has view it??

I have been trying with no success :/

Thanks
stivens is offline
Reply With Quote
View Public Profile
 
Old 02-07-2012, 05:03 AM Re: change color of unread messages
miki86's Avatar
Extreme Talker

Posts: 239
Location: print_r($serbia);
Trades: 0
JavaScript Cookies: http://www.w3schools.com/js/js_cookies.asp

You need a mouseover event for that tip, then just check what is under the mouse pointer, get it's ID, change the cookie state and change the class.

This function will change the cookie:

PHP Code:
function setCookie(c_name,value,exdays)
 {
     var 
exdate=new Date();
     
exdate.setDate(exdate.getDate() + exdays);
     var 
c_value=escape(value) + ((exdays==null) ? "" "; expires="+exdate.toUTCString());
     
document.cookie=c_name "=" c_value;
 } 
Pass the cookie name and value, if the cookie exist it will change it's value, if not it will create a new one.
miki86 is offline
Reply With Quote
View Public Profile
 
Old 02-07-2012, 03:39 PM Re: change color of unread messages
Super Talker

Posts: 112
Name: Joan
Trades: 0
Thanks for your help, i'm trying this right now..
stivens is offline
Reply With Quote
View Public Profile
 
Old 02-24-2012, 07:14 AM Re: change color of unread messages
Experienced Talker

Posts: 35
Name: Julie Watson
Trades: 0
Thanks for sharing information about this. this information is really useful and quite interesting one. i will try for running java script.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by julie9999; 02-24-2012 at 07:15 AM..
julie9999 is offline
Reply With Quote
View Public Profile Visit julie9999's homepage!
 
Old 03-07-2012, 11:03 AM Re: change color of unread messages
Novice Talker

Posts: 6
Trades: 0
Thanks. I like your idea about the cookie
BradCliff is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to change color of unread messages
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23402 seconds with 11 queries