Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

NEED JAVASCRIPT HELP PLZ!!

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-17-2004, 09:04 PM
 
Local Hero Local Hero is offline
 

Senior Member
  
Join Date: May 2004
Location: UT
Posts: 121
 

Default 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>
__________________
X-Cart version 4.4.5
X-Cart version 5.3.2.8
Reply With Quote
  #2  
Old 10-18-2004, 03:31 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

wrap javascript in literal tags

{literal} javacode here {/literal}
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 10-18-2004, 08:04 PM
 
Local Hero Local Hero is offline
 

Senior Member
  
Join Date: May 2004
Location: UT
Posts: 121
 

Default

I don't understand. Which parts to I put {} around? Sorry, I'm kind of a beginner at JavaScript. Thanks.
__________________
X-Cart version 4.4.5
X-Cart version 5.3.2.8
Reply With Quote
  #4  
Old 10-18-2004, 08:55 PM
  Gijs's Avatar 
Gijs Gijs is offline
 

eXpert
  
Join Date: Aug 2004
Location: Belgium
Posts: 295
 

Default

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
__________________
X-cart 4.1.11
PHP 5 MySQL 5
www.wheelpalace.eu
Reply With Quote
  #5  
Old 10-20-2004, 12:46 PM
 
Local Hero Local Hero is offline
 

Senior Member
  
Join Date: May 2004
Location: UT
Posts: 121
 

Default

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>
__________________
X-Cart version 4.4.5
X-Cart version 5.3.2.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:13 PM.

   

 
X-Cart forums © 2001-2020