Second time around the goldfish bowl
I've a JS file that isn't behaving according to my liking. I'm trying to determine the checked and radio buttons associated with a purchase and create hidden fields to pass through to a cart page. The problem is it seems to double-up items in the array. For example, if a user chooses "foursome", there appears two foursomes in the product array.
var total = 0;
var holes = Number(document.golfReg2010.holes.value);
var sassy = document.golfReg2010.elements.length;
var bugger = document.golfReg2010.sponLevel.length;
var s = 0;
var bub = document.golfReg2010.elements[i].name;
total = total + 150;
total = total + 550;
sLevel = GetCheckedValue(document.golfReg2010.sponLevel[s]);
total = total + 3500;
total = total + 2250;
total = total + 1200;
total = total + (350*holes);
product.push("Hole Sponsorship (" + holes.toString() + " total)");
alert("Please report this as an error to the administrator");
total = total + Number(document.golfReg2010.acsContribution.value);
total = total + ".00"
document.getElementById("UMamount").value = total;
So it's something in the switch
So basically I'm not understanding why:
The switch statement seems to be worthless for looping through a section of the form and determining which items are checked. On every trip around, it's still getting into the previous CASE item and adding to the array. So if I choose the individual checkbox (first in the order), I'll end up with it appearing three times in the array of product. Seems to me the CASE statement shouldn't evaluate the item each time, since the variable changes on each loop through. What is going on here that is does this?
Could you upload the whole form with the script on a server and post the link? If it's not too much trouble, remove all other crap from the whole page but leave the form fully functional. And we'll go from there. If you can't do that, zip it all up and post here.
i love easter eggs
(if you got any creative easter eggs, send me a PM)
Ok, sorry for the delay
As I stated, It would seem to me that the Case Switch wouldn't add multiple instances of a product to the array Product since each time around the For loop, the variable will change to the next form item.
Last edited by Techmaniac; 05-14-2010 at 09:21 AM.
Reason: attachment didn't work
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)