drej
10-08-2002, 04:43 PM
I am trying to pass an ASP variable into an external JavaScript and use the ASP variable as the image path for a rollover image.
The script works when I use the image path (without the variable). The version below returns a broken image link when I rollover the first image. The variable value is the correct path to the image, but it's not working in the JavaScript.
If I take the quotes out I get all kind of object errors, etc.
I'm trying to do this so that I can manage the button image changes (active link, current section, etc.) from one ASP include file.
Thanks for any ideas.
<!--
//main navigation
if (document.images) { // Active Images
img1on = new Image();
img1on.src="<%=img1varon%>";
//Services
img2on = new Image();
img2on.src="http://www.liqmedia.com/futuretech/site/global_images/services_over.jpg";
//Clients
img3on = new Image();
img3on.src="http://www.liqmedia.com/futuretech/site/global_images/clients_over.jpg";
//News & Events
img4on = new Image();
img4on.src="http://www.liqmedia.com/futuretech/site/global_images/newsevents_over.jpg";
//Resources
img5on = new Image();
img5on.src="http://www.liqmedia.com/futuretech/site/global_images/resources_over.jpg";
//Careers
img6on = new Image();
img6on.src="http://www.liqmedia.com/futuretech/site/global_images/careers_over.jpg";
//Site Map
img7on = new Image();
img7on.src="http://www.liqmedia.com/futuretech/site/global_images/sitemap_over.jpg";
//Contact Us
img8on = new Image();
img8on.src="http://www.liqmedia.com/futuretech/site/global_images/contactus_over.jpg";
//Employee Communication
img9on = new Image();
img9on.src="http://www.liqmedia.com/futuretech/site/global_images/empcomm_over.jpg";
//Custom Training & Instructional Design
img10on = new Image();
img10on.src="http://www.liqmedia.com/futuretech/site/global_images/custrain_over.jpg";
//Communication Staffing & Recruiting
img11on = new Image();
img11on.src="http://www.liqmedia.com/futuretech/site/global_images/commstaff_over.jpg";
//Communication Workshops
img12on = new Image();
img12on.src="http://www.liqmedia.com/futuretech/site/global_images/commwork_over.jpg";
//About Us
img1off = new Image();
img1off.src="http://www.liqmedia.com/futuretech/site/global_images/aboutus_reg.jpg";
//Services
img2off = new Image();
img2off.src="http://www.liqmedia.com/futuretech/site/global_images/services_reg.jpg";
//Clients
img3off = new Image();
img3off.src="http://www.liqmedia.com/futuretech/site/global_images/clients_reg.jpg";
//News & Events
img4off = new Image();
img4off.src="http://www.liqmedia.com/futuretech/site/global_images/newsevents_reg.jpg";
//Resources
img5off = new Image();
img5off.src="http://www.liqmedia.com/futuretech/site/global_images/resources_reg.jpg";
//Careers
img6off = new Image();
img6off.src="http://www.liqmedia.com/futuretech/site/global_images/careers_reg.jpg";
//Site Map
img7off = new Image();
img7off.src="http://www.liqmedia.com/futuretech/site/global_images/sitemap_reg.jpg";
//Contact Us
img8off = new Image();
img8off.src="http://www.liqmedia.com/futuretech/site/global_images/contactus_reg.jpg";
//Employee Communication
img9off = new Image();
img9off.src="http://www.liqmedia.com/futuretech/site/global_images/empcomm_reg.jpg";
//Custom Training & Instructional Design
img10off = new Image();
img10off.src="http://www.liqmedia.com/futuretech/site/global_images/custrain_reg.jpg";
//Communication Staffing & Recruiting
img11off = new Image();
img11off.src="http://www.liqmedia.com/futuretech/site/global_images/commstaff_reg.jpg";
//Communication Workshops
img12off = new Image();
img12off.src="http://www.liqmedia.com/futuretech/site/global_images/commwork_reg.jpg";
}
// Function to 'activate' images.
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}
// Function to 'deactivate' images.
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}
//-->
The script works when I use the image path (without the variable). The version below returns a broken image link when I rollover the first image. The variable value is the correct path to the image, but it's not working in the JavaScript.
If I take the quotes out I get all kind of object errors, etc.
I'm trying to do this so that I can manage the button image changes (active link, current section, etc.) from one ASP include file.
Thanks for any ideas.
<!--
//main navigation
if (document.images) { // Active Images
img1on = new Image();
img1on.src="<%=img1varon%>";
//Services
img2on = new Image();
img2on.src="http://www.liqmedia.com/futuretech/site/global_images/services_over.jpg";
//Clients
img3on = new Image();
img3on.src="http://www.liqmedia.com/futuretech/site/global_images/clients_over.jpg";
//News & Events
img4on = new Image();
img4on.src="http://www.liqmedia.com/futuretech/site/global_images/newsevents_over.jpg";
//Resources
img5on = new Image();
img5on.src="http://www.liqmedia.com/futuretech/site/global_images/resources_over.jpg";
//Careers
img6on = new Image();
img6on.src="http://www.liqmedia.com/futuretech/site/global_images/careers_over.jpg";
//Site Map
img7on = new Image();
img7on.src="http://www.liqmedia.com/futuretech/site/global_images/sitemap_over.jpg";
//Contact Us
img8on = new Image();
img8on.src="http://www.liqmedia.com/futuretech/site/global_images/contactus_over.jpg";
//Employee Communication
img9on = new Image();
img9on.src="http://www.liqmedia.com/futuretech/site/global_images/empcomm_over.jpg";
//Custom Training & Instructional Design
img10on = new Image();
img10on.src="http://www.liqmedia.com/futuretech/site/global_images/custrain_over.jpg";
//Communication Staffing & Recruiting
img11on = new Image();
img11on.src="http://www.liqmedia.com/futuretech/site/global_images/commstaff_over.jpg";
//Communication Workshops
img12on = new Image();
img12on.src="http://www.liqmedia.com/futuretech/site/global_images/commwork_over.jpg";
//About Us
img1off = new Image();
img1off.src="http://www.liqmedia.com/futuretech/site/global_images/aboutus_reg.jpg";
//Services
img2off = new Image();
img2off.src="http://www.liqmedia.com/futuretech/site/global_images/services_reg.jpg";
//Clients
img3off = new Image();
img3off.src="http://www.liqmedia.com/futuretech/site/global_images/clients_reg.jpg";
//News & Events
img4off = new Image();
img4off.src="http://www.liqmedia.com/futuretech/site/global_images/newsevents_reg.jpg";
//Resources
img5off = new Image();
img5off.src="http://www.liqmedia.com/futuretech/site/global_images/resources_reg.jpg";
//Careers
img6off = new Image();
img6off.src="http://www.liqmedia.com/futuretech/site/global_images/careers_reg.jpg";
//Site Map
img7off = new Image();
img7off.src="http://www.liqmedia.com/futuretech/site/global_images/sitemap_reg.jpg";
//Contact Us
img8off = new Image();
img8off.src="http://www.liqmedia.com/futuretech/site/global_images/contactus_reg.jpg";
//Employee Communication
img9off = new Image();
img9off.src="http://www.liqmedia.com/futuretech/site/global_images/empcomm_reg.jpg";
//Custom Training & Instructional Design
img10off = new Image();
img10off.src="http://www.liqmedia.com/futuretech/site/global_images/custrain_reg.jpg";
//Communication Staffing & Recruiting
img11off = new Image();
img11off.src="http://www.liqmedia.com/futuretech/site/global_images/commstaff_reg.jpg";
//Communication Workshops
img12off = new Image();
img12off.src="http://www.liqmedia.com/futuretech/site/global_images/commwork_reg.jpg";
}
// Function to 'activate' images.
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}
// Function to 'deactivate' images.
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}
//-->