X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   NEED JAVASCRIPT HELP PLZ!! (https://forum.x-cart.com/showthread.php?t=9889)

Local Hero 10-17-2004 09:04 PM

NEED JAVASCRIPT HELP PLZ!!
 
Hey, I'm having a bit of a problem with JavaScript and X-Cart on a static page. I'm trying to make it so when the user selects the color of an item from a dropdown box, it changes the image to the appropriate color AND keeps the value of the dropdown box so the user can see which one he chose when viewing the cart contents. If you need to know I'm on Xcart version 3.5.6. I have the image swapping working, but I can't get the value of the textbox to transfer to the cart. Is it because of the brackets [] ?


Any help is greatly appreciated! THANK YOU!

Here's the page:http://www.localheroclothing.com/staticlongsleeve.html

Here's my code:

<html><head>

<title>Local Hero Clothing</title>

<link rel="stylesheet" href="herostyle.css" type="text/css">

<Script Language=Javascript>

function showcolor()
{
var varcolorcode=document.orderform_16134.color.option s[document.orderform_16134.color.selectedIndex].value;
var imgname="cc_" + varcolorcode + ".jpg";
document.images["colorcodeurl"].src=imgname;
document.images["enlargepic"].src="/images/enlarge.gif";
}

function loadstring()
{
var colorvalue=document.orderform_16134.color.options[document.orderform_16134.color.selectedIndex].value;
}
</SCRIPT>


</head>

<body>



<tr><td>

<form name="orderform_16134" method=post action="http://www.localheroclothing.com/store/customer/cart.php">
<input type=hidden name=mode value=add>
<input type=hidden name=productid value="16134">


<tr>

<!--<td nowrap valign="middle" rowspan="2" align="center">
[img]images/1x1t.gif[/img]-->

</td>
</tr>
<tr>
<td nowrap><font face="Arial" size="2" color="white">Select Color</font></td><td>
<select size="1" name="color" onChange="showcolor(); document.orderform_16134.product_options[color].value=document.orderform_16134.color.options[document.orderform_16134.color.selectedIndex].value;">
<option SELECTED value="yellowblock">Yellow</option><option value="redblock">Red</option>
</select><font size="1"></font></td>

</tr>






<tr>
<td height=25>
<font color="white">Size
</td>
<td >
<select name="product_options[Size]">
<option value=0>S</option>
<option value=1>M</option>
<option value=2>L</option>
<option value=3>XL</option>
</select>
</td>
</tr>


<tr><td height=25 width=30%><font color="white">Quantity</td>
<td>
<input type=hidden name=amount value="1">

<select name=amount>

<option value="1" >1</option>
select>
</select>

<input type=hidden name="product_options[color]" value="">
</td></tr>

<tr>
<td nowrap valign="middle" rowspan="2" align="center">
[img]images/1x1t.gif[/img]
</td></tr>

<tr><td colspan=1><center>

<font class=FormButton>Add to cart </font>http://www.localheroclothing.com/store/skin1/images/GOboutonWhiteBkg.gif

</td></tr>
</table>
</body>
</html>

shan 10-18-2004 03:31 AM

wrap javascript in literal tags

{literal} javacode here {/literal}

Local Hero 10-18-2004 08:04 PM

I don't understand. Which parts to I put {} around? Sorry, I'm kind of a beginner at JavaScript. Thanks.

Gijs 10-18-2004 08:55 PM

Quote:

Originally Posted by Local Hero
I don't understand. Which parts to I put {} around? Sorry, I'm kind of a beginner at JavaScript. Thanks.


Forum faq:http://forum.x-cart.com/viewtopic.php?t=686
Look at Funkydunk's second answer on page1

Local Hero 10-20-2004 12:46 PM

Thank you for your reply. I've got it so that when you add the item to the cart it shows which color you chose, but now the image swap doesn't work. Can you help me figure out why? In case I forgot to say, this is a static page. Here is the code:

Code:

<Script Language=Javascript>
<!-- HIDE FROM OLD BROWSERS
function showcolor()
{
        var varcolorcode=document.orderform_16134.product_options[color].options[document.orderform_16134.product_options[color].selectedIndex].value;
        var imgname="cc_" + varcolorcode + ".jpg";
        document.images["colorcodeurl"].src=imgname;
        document.images["enlargepic"].src="/images/enlarge.gif";
}

function loadstring()
{
        var colorvalue=document.orderform_16134.product_options[color].options[document.orderform_16134.product_options[color].selectedIndex].value;
}

// STOP HIDING -->

      document.write('<select size="1" name="product_options[color]" onChange="showcolor(); "><option SELECTED value="yellowblock">Yellow</option><option value="redblock">Red</option></select><font size="1">');
</script>



All times are GMT -8. The time now is 05:41 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.