PDA

View Full Version : Perl + DHTML



joe.ohallaron
06-12-2006, 07:24 PM
Hello, I was just using this tooltip thing Here (http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm) . I have a perl script that returns just some plain text when it's called and I was wondering if anyone knew how to make it so that the text from the perl script will show up in the boxes.

I guess I'm just not sure how to make the perl script run and store the information without actually clicking the link. I just want the information to show up in the pop up window when rolled over.

Thanks.

djr33
06-12-2006, 07:30 PM
Perl is server side.... it's not interactive... must be run on the server then it outputs text/etc.
You may wish to call it via AJAX, like you would with php. I'd look into that.

joe.ohallaron
06-12-2006, 07:43 PM
So I guess you can't just get the server to run the script when you rollover things? Do you know any good AJAX resources or tutorials or anything? Any more information would be helpful. Thanks.

-Joe O'Hallaron

Twey
06-12-2006, 07:56 PM
Add this:
var xht = (function() {
if(typeof ActiveXObject == "undefined" && typeof XMLHttpRequest == "undefined") return null;
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
}
@else xmlhttp = null;
@end @*/

if (xmlhttp == null && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = null;
}
}
return xmlhttp;
})();
Take this function:
function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}Replace it with this:
function ddrivetip(theurl, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
if(xht) {
xht.open("GET", theurl, false);
xht.send(null);
tipobj.innerHTML = xht.responseText;
} else tipobj.innerHTML = "Unfortunately, an error has occurred. Please report this to the site administrators, including the browser you were using at the time and what you were attempting to do.";
enabletip=true
return false
}
}
Use the URL to your Perl script instead of the text to display.

Strangeplant
06-13-2006, 12:56 PM
Nice and concise. BTW, this thread is already Googled.