Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

USING JAVA SCRIPT IN PRODUCT DESCRIPTION???


kylebassett

Recommended Posts

Posted

Hi everyone - wondering if someone can help me out! I am using a javascript for my description for each product... it works fine when i view it as a .htm file - here is the link and what it is suppost to do!

 

http://theonestore.hn.org/estoredev/catalog/index.htm

 

When I paste the code in the description field, it seems to display correct - it also does the switch - but it seems to change the link to # and displays the first screen of my store... I was wondering if someone can look at the code and let me know how to make this work - I want it to switch the picture and stay where it is...

 

Here is the java script I am using...

 

Thanks in advance everyone!!!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<html>

 

<head>

<meta http-equiv="Content-Language" content="en-us">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta name="generator" content="Microsoft FrontPage 5.0">

<title>The One Clothing Company</title>

 

<script TYPE="text/javascript">

<!--

 

function newImage(arg) {

if (document.images) {

rslt = new Image();

rslt.src = arg;

return rslt;

}

}

 

function changeImages() {

if (document.images && (preloadFlag == true)) {

for (var i=0; i<changeImages.arguments.length; i+=2) {

document[changeImages.arguments].src = changeImages.arguments[i+1];

}

}

}

 

var preloadFlag = false;

function preloadImages() {

if (document.images) {

tayl01 = newImage("images/taylor01.gif");

tayl02 = newImage("images/taylor02.gif");

tayl03 = newImage("images/taylor03.gif");

preloadFlag = true;

}

}

 

// -->

</SCRIPT>

</head>

<BODY STYLE="MARGIN:0" ONLOAD="preloadImages();">

<p style="margin-top: 0; margin-bottom: 0" align="left"><b>

<font face="Tahoma" size="1">THE ONE ALLOWS YOU TO CUSTOM BUILD YOU OWN

HOODY.</font></b></p>

<p style="margin-top: 0; margin-bottom: 0" align="left"><b>

<font face="Tahoma" size="1">CHOOSE THE STYLE THAT BEST FITS YOUR

PERSONAL STYLE...</font></b></p>

<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="16%" id="AutoNumber1" height="210">

<tr>

<td width="15%" height="208">

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor01.gif'); return true;">

<img src="images/whiteyl01.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">RED/WHITE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor03.gif'); return true;"><img src="images/tayl03.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">GREEN/WHITE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor05.gif'); return true;"><img src="images/tayl05.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">PURPLE/RED</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor07.gif'); return true;"><img src="images/tayl07.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">BABYBLUE/BLUE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor09.gif'); return true;"><img src="images/tayl09.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">BLACK/BLACKE</font></td>

<td width="58%" height="208">

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" ONCLICK="self.close(); java script:opener.location.href=''; opener.shut=false"><img src="images/taylor01.gif" alt="" name="preview" height="234" width="175" border="0"></A></td>

<td width="79%" height="208">

<p style="margin-top: 0; margin-bottom: 0" align="center"> <A HREF="#" onClick="changeImages('preview', 'images/taylor02.gif'); return true;"><img src="images/tayl02.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font face="Tahoma" size="1">YELLOW/WHITE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor04.gif'); return true;">

<img src="images/whiteyl04.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">PINK/WHITE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor06.gif'); return true;">

<img src="images/whiteyl06.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">BLUE/WHITE</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor08.gif'); return true;">

<img src="images/whiteyl08.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">MAROON/YELLOW</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<A HREF="#" onClick="changeImages('preview', 'images/taylor10.gif'); return true;">

<img src="images/whiteyl010.gif" alt="" width="50" height="47" border="0"></A></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font size="1" face="Tahoma">BLACK/WHITE</font></td>

</tr>

</table>

<p style="margin-top: 0; margin-bottom: 0" align="left"><b>

<font face="Tahoma" color="#ff0000" size="1">* PLEASE CHOOSE YOUR

OPTIONS AT THE BOTTOM OF THIS PAGE</font></b></p>

<p style="margin-top: 0; margin-bottom: 0" align="left"><b>

<font face="Tahoma" color="#ff0000" size="1">* YOUR CUSTOM ORDER WILL

SHIP WITH-IN 2 WEEKS</font></b></p>

<p style="margin-top: 0; margin-bottom: 0" align="left"><b>

<font face="Tahoma" size="1"><font color="#ff0000">* CLICK TO VIEW:</font>

<a href="http://theonestore.hn.org/estore/hoodysizechart.gif" target="_blank">

SIZE CHART</a></font></b></p>

</body>

 

</html>

Posted

firstly, you need to just add the code to change the image and the image itself not the entire html file.

 

then instead of using links like

 

<A HREF="#" onClick="changeImages('preview', ' .....

 

use <A HREF="java script:void(0)" onClick="ch ....

 

then it won't change the page.

Posted

http://theonestore.hn.org/estoredev/catalo...?products_id=77

 

ok i am confussed... i have changed the code - when you first load the page and try to switch the picture it doesn't display...

 

I have left the image in the bottom right with the link to # - when you click on it it takes you to the front of the store - if you click back - it then work s on the first 3 - red/white - yellow/white - green/white - but nothing after that...

 

i am very confussed - all hte other code seems the same but not acting the dsame...

 

Any java people that can help me out thanks very much!!!

  • 9 months later...
Posted

Kyle,

Your script is awesome!

Can you post the working script please?

You found a great solution to the lack of product attributes control in osc.

It would be great to have the images change when the option was selected, wouldn't it?

I'll try it your way, if you would please update this thread!

Any one else with suggestions on how to make the option change active, please also post!

:-j.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...