| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
variations javascript help | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() Hi all,
I've got some product variations happening and I've added the mod that adds the "select <option>" into the drop-down menu of the product variations. (works great!) I started with one variation, added the javascript in the product options page and all was well. Now that I have two variations, I need a bit of help getting the right javascript happening. ![]() Here is what I had for one variation that worked: Code:
Code:
I've tried a buch of different things with the Javascript for two products. I nearly had it working once but one of the things wrong was that it was opening an alert for the size, I'd click ok and immediatly another would open with the colour. I thought if there were going to be two alerts I'd rather have a script that had three alerts: 1- please choose a size and colour (if neither are selected) 2- please choose a size (if only the colour has been chosen) 3- please choose a colour (if only the size has been chosen) -hroth |
|||||||||
#2
|
|||||||
|
|||||||
![]() Quote:
the reason you get one alert after another is because of your "if" statement...you have 2 "if" statements, but seems what you want is a "if,elseif" statement, ie: if (neither selected) alert (both not selected) elseif (color selected) alert (size not selected) elseif (size selected) alert (color not selected) else (submit) also, if you dont use color-size combo validations, then you can just change the if statement to check if the index is 0 or if the value contains "select" instead of checking against all the sizes and colors |
|||||||
#3
|
|||||||||
|
|||||||||
![]() thanks inebriate.. I've tried what I can of your suggestions. I have not been able to try it fully becaue I'm not a "JavaScript'r"
(I'm much better at actionscript) I'll expand on what has been modified. I think I might have left out some important info (sorry) this is from the post: http://forum.x-cart.com/showpost.php?p=179500&postcount=18 modifying customer_options.tpl I replaced: Code:
Code:
I wish I knew how to take your advice regarding: Quote:
I don't know how check for what shows as the default value of the drop down menus. When I create the variations, I add only XL, L, M and small for men_size and black, offwhite for colour_001. It worked perfectly with one drop down.. I've tried about 50 variation in as many ways as I can to get it to work with two. I really appreciate the help but sadly I just don't get it yet ![]() my latest rendition (still wrong) looks like this: Code:
I changed off-white to offwhite because I thought it might cause a problem. I tried using elseif and I've tried removing the "return false" in a few places. I've tried an elseif where you see the else. .. still trying.. still experimenting.. but still in need of help~! when I view the source of the page I see this where the drop down menus are: Code:
|
|||||||||
#4
|
|||||||
|
|||||||
![]() change it to
Code:
in the next few days i will be posting up a mod to check if all the options have been selected, i posted the pseduocode to it in that other thread you mentioned |
|||||||
#5
|
|||||||||
|
|||||||||
![]() Hi inebriate,
I tried the script and It did not fly. I might be putting it into the wrong place.. I've been putting it into the bottom field (Validation script) in the admin - product options page of this product. Perhaps in need to be in a .js file? I ran it in firefox just to have the error cosole tell me what it sees. firefox says: "missing ; before statement" elseif (val1 > -1){ ---------------------^ it has a link to follow, and here Is the full script as it shows: Code:
so I took this and pasted it into an online javascrip validator: http://www.jslint.com/ It returned this: Quote:
All I know is that it remains a puzzle. I hope this information helps! -hroth I really appreciate this help! |
|||||||||
#6
|
|||||||||
|
|||||||||
![]() I got it working.
I thought I'd share the script I came up with. This goes in the Validation script window on the bottom of the product options page. Code:
works nice now - WOO!! far from the ideal solution but hey.. it's doing what I needed it to! -hroth |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|