|
#1
|
|||
|
|||
|
I want a JavaScript on mouseover tooltip that will display dyanmic content, from a MySQL database. Basically, when you move over the image, the tooltip pops up with information specific to that image. The relevant information would have already been accessed on the php page, and stored in an array.
It's on phpBB if that makes a difference Is this possible, and if so how please? |
|
#2
|
||||
|
||||
|
I am sure it is possible. How comfortable are you with modifying javascript to accept php variables?
There are a number of tool tip javascripts available here on DD as well as elsewhere. Start with a good one (make sure that it works well in all your target browsers). Then you have two basic approaches available, you may simply insert your php variables directly into the script on the page, or have an external file, which when populated by the server is a javascript array and link that .php file to the page that needs to use it as though it were an ordinary .js file, only with the .php extension. Example of linking a php file to a page as though it were an external javascript: HTML Code:
<script type="text/javascript" src="myscript.php"></script> \" or: \'
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#3
|
|||
|
|||
|
I have a tooltip script on my site that came with a mod I installed (sorry, should have mentioned this). I would prefer to use this if possible. It's this one: http://migoicons.tripod.com/dhtips.htm
The script is referenced at the top of the page with Code:
<div id="TipLayer" style="visibility:hidden;position:absolute;z-index:1000;top:-100;"></div>
<script language="JavaScript1.2" src="adr/language/lang_{LANG}/lang_adr_buildings.js" type="text/javascript"></script>
The mousover script is Code:
onMouseOver="stm(Text[100],Style[0])" onMouseOut="htm()" Code:
/* Please refer to readme.html for full Instructions Text[...]=[title,text] Style[...]=[TitleColor,TextColor,TitleBgColor,TextBgColor,TitleBgImag,TextBgImag,TitleTextAlign,TextTextAlign, TitleFontFace, TextFontFace, TipPosition, StickyStyle, TitleFontSize, TextFontSize, Width, Height, BorderSize, PadTextArea, CoordinateX , CoordinateY, TransitionNumber, TransitionDuration, TransparencyLevel ,ShadowType, ShadowColor] */ var FiltersEnabled = 1 // If your Not going To use transitions Or filters In any of the tips Set this To 0 Text[100]=["Teleport Map","View all of the realm, Teleport if you have the scroll"] Style[0]=["white","#FF9000","#FF9000","#242424","","","","","","","","","","",100,"",2,2,10,10,51,0.5,75,"simple","gray"] applyCssFilter() |
|
#4
|
||||
|
||||
|
If I have this straight, there is a file named:
lang_adr_buildings.js that among other things contains: Code:
Text[100]=["Teleport Map","View all of the realm, Teleport if you have the scroll"] lang_adr_buildings.php and replace the above text strings in it with something like: Code:
Text[100]=["<?php page_content(x)?>","<?php page_content(y)?>"] Title: "Castle Keep" in the data base, then in the data base it would need to be changed to: Title: \"Castle Keep\" so its quotes would not be confused with the end quotes in the array (red in the above). You would have to call lang_adr_buildings.php on the page using its new .php extension (the language attribute has been deprecated - it's no longer needed): HTML Code:
<script src="adr/language/lang_{LANG}/lang_adr_buildings.php" type="text/javascript"></script>
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#5
|
|||
|
|||
|
Yes, it's a php with a tpl file(phpBB). I'll have a go with this and see what happens. Thanks.
|
|
#6
|
|||
|
|||
|
Okay, I'm doing something wrong here. I've got the following code in the overall_header.tpl to enable the javascript:
Code:
<SCRIPT src="adr/includes/functions_adr_graveyard_popup.js" type="text/javascript"></SCRIPT> Then, at the top of the tpl where I want the popup to appear, I have: Code:
<div id="TipLayer" style="visibility:hidden;position:absolute;z-index:1000;top:-100;"></div>
<script src="adr/language/lang_{LANG}/lang_adr_buildings.php" type="text/javascript"></script>
Again, that file exists, which is here: Code:
/*
Please refer to readme.html for full Instructions
Text[...]=[title,text]
Style[...]=[TitleColor,TextColor,TitleBgColor,TextBgColor,TitleBgImag,TextBgImag,TitleTextAlign,TextTextAlign, TitleFontFace, TextFontFace, TipPosition, StickyStyle, TitleFontSize, TextFontSize, Width, Height, BorderSize, PadTextArea, CoordinateX , CoordinateY, TransitionNumber, TransitionDuration, TransparencyLevel ,ShadowType, ShadowColor]
*/
var FiltersEnabled = 1 // If your Not going To use transitions Or filters In any of the tips Set this To 0
Text[999]=["R.I.P.","<?php {L_CHARACTER_NAME} ?>"]
Style[0]=["white","#FF9000","#FF9000","#242424","","","","","","","","","","",100,"",2,2,10,10,51,0.5,75,"simple","gray"]
applyCssFilter()
Code:
onMouseOver="stm(Text[999],Style[0])" onMouseOut="htm()" |
|
#7
|
||||
|
||||
|
Well, doing it that way will pull the value (if any) of:
PHP Code:
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#8
|
||||
|
||||
|
Change
Code:
<div id="TipLayer" style="visibility:hidden;position:absolute;z-index:1000;top:-100;"></div>
<script src="adr/language/lang_{LANG}/lang_adr_buildings.php" type="text/javascript"></script>
Code:
<div id="TipLayer" style="visibility:hidden;position:absolute;z-index:1000;top:-100;"></div>
<script src="adr/language/lang_{LANG}/lang_adr_buildings.php?LCN={L_CHARACTER_NAME}" type="text/javascript"></script>
Code:
Text[999]=["R.I.P.","<?php {L_CHARACTER_NAME} ?>"]
Code:
Text[999]=["R.I.P.","<?php echo $_GET['LCN']; ?>"]
__________________
-Brady |
|
#9
|
||||
|
||||
|
blm126 & egdcltd -
blm126's suggestion is certainly worth a try but, I don't see how that would update the value in real time. If it does, I am glad and will have learned something. My idea is to pull the variable at the time that it is needed by appending a script to the page. There are probably more efficient ways to make a value like that available in real time, but attaching a script is one: Put this script on the page: Code:
<script type="text/javascript">
function attach(num, run){
if(!run){
Text[num]=null;
var theScript=document.createElement('script');
theScript.type='text/javascript';
theScript.src='charName'+num+'.php';
document.getElementsByTagName('head')[0].appendChild(theScript);
}
if (Text[num]!=null)
stm(Text[num],Style[0]);
else
setTimeout("attach("+num+", 1)", 60);
}
</script>
Code:
Text[999]=["R.I.P.","<?php {L_CHARACTER_NAME} ?>"]
Code:
onMouseOver="attach(999);"
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#10
|
|||
|
|||
|
Currently, at the moment the problem is that the popup isn't actually popping up. I don't know if thereis a problem with passing the variables. yet.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|