Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2013, 01:12 PM   PM User | #1
mharrison
New Coder

 
Join Date: Dec 2012
Posts: 52
Thanks: 12
Thanked 0 Times in 0 Posts
mharrison is an unknown quantity at this point
Page Preview code

I found this website:
http://psoug.org/snippet/Javascript-...-Hover_216.htm

Which contains the javascript code for having a page preview open up when you mouse over a link.

Right now I have the following being echoed to create a link from two fields in my database:

PHP Code:
echo "<td><a href=\"".$row['lnktxt']."\" target=_blank>".$row['dsptxt']."</a></td>"
I'm having trouble figuring out how I can merge the code I have with the code from the website:

Code:
<a href="#" onMouseOver="toggleDiv('div1',1,'http://www.google.com')" onMouseOut="toggleDiv('div1',0,'http://www.google.com')">Link 1!</a>
Can anyone help me figure out how I can do this, or even if I can be done?

Thanks!

Last edited by mharrison; 01-04-2013 at 01:23 PM..
mharrison is offline   Reply With Quote
Old 01-04-2013, 01:33 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
I'll take a shot at it ...

PHP Code:
echo "<td><a href=\"".$row['lnktxt']."\" target=\"_blank\" onMouseOver=\"toggleDiv('div1',1,'".$row['lnktxt']."')\" onMouseOut=\"toggleDiv('div1',0,'".$row['lnktxt']."')\" >".$row['dsptxt']."</a></td>"

.
mlseim is offline   Reply With Quote
Old 01-04-2013, 01:34 PM   PM User | #3
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
That code is ancient. Even though it states it was last edited in 2009, it will have been many years before that!

[language="JavaScript", capitalised TAGS, document.layers are the clues.]

I suggest that you find more recent code before attempting to merge it with yours.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 01-04-2013, 01:35 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Andrew is correct ... maybe AJAX (some PHP/JQuery) would be better.
I don't have an example to show.
mlseim is offline   Reply With Quote
Old 01-04-2013, 01:49 PM   PM User | #5
mharrison
New Coder

 
Join Date: Dec 2012
Posts: 52
Thanks: 12
Thanked 0 Times in 0 Posts
mharrison is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
Andrew is correct ... maybe AJAX (some PHP/JQuery) would be better.
I don't have an example to show.
Ancient it may be, but it is the best example I have found so far that doesn't completely go over my head or require me to create image snapshots of all 21+ thousand links I have in my database.

Thanks anyways, I'll keep looking.

FYI, thanks for taking a shot at merging the code. When I uploaded I ended up with the following error:
Code:
Parse error: syntax error, unexpected 'div1' (T_STRING), expecting ',' or ';' in /homepages
mharrison is offline   Reply With Quote
Old 01-04-2013, 11:14 PM   PM User | #6
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Try this:

PHP Code:

echo "<td><a href=\"{$row['lnktxt']}\" target=\"_blank\" onMouseOver=\"toggleDiv('div1',1,'{$row['lnktxt']}')\" onMouseOut=\"toggleDiv('div1',0,'{$row['lnktxt']}')\" >{$row['dsptxt']}</a></td>"

.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 03:45 PM.


Advertisement
Log in to turn off these ads.