| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
NEED JAVASCRIPT HELP PLZ!! | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
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 |
|||||||
#2
|
|||||||||
|
|||||||||
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 |
|||||||||
#3
|
|||||||
|
|||||||
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 |
|||||||
#4
|
|||||||||
|
|||||||||
Quote:
Forum faq:http://forum.x-cart.com/viewtopic.php?t=686 Look at Funkydunk's second answer on page1 |
|||||||||
#5
|
|||||||
|
|||||||
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:
__________________
X-Cart version 4.4.5 X-Cart version 5.3.2.8 |
|||||||
|
|||
X-Cart forums © 2001-2020
|