
The problem is that on a webpage.asp, the items size with corresponding price does not transfer correctly to the shopping cart if the value of the size is a numeric value. It works fine if the size is a text value.
Let's take ItemA for example:
Item A comes in small for $2 and medium for $4.
I choose the radio button for the medium item and click "add to cart".
The cart reads as follows (which is correct):
ItemA: ItemA:medium @ 4
Price: $4
However, Lets take ItemB for example:
Item B comes in sizes 16" for $2 and 18" for $4.
I choose the radio button for the 18" item and click "add to cart".
The cart reads as follows (which is not correct):
ItemB: ItemB:18
Price: $2
The code that I think pertains to this issue is posted below:
The first section is the javascript code and the second section is the excerpt from the form.
function ReadForm (obj1, tst) { // process radio and checkbox
var i,amt,des,obj,pos,val;
amt = obj1.baseamt.value*1.0; // base amount
des = obj1.basedes.value; // base description
for (i=0; i<obj1.length; i++) { // run entire form
obj = obj1.elements[i]; // a form element
if (obj.type == "checkbox" || // checkboxes
obj.type == "radio") { // and radios
if (obj.checked) { // did user check it?
val = obj.value; // the value of the selection
pos = val.indexOf ("@"); // price set?
if (pos >= 0) amt = val.substring (pos + 1)*1.0;
pos = val.indexOf ("+"); // price increment?
if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
pos = val.indexOf ("%"); // percent change?
if (pos >= 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
if (des.length == 0) des = val;
else des = des + ", " + val; // accumulate value
}
<input name="Size" type="radio" id="Size"
onclick="ReadForm (this.form, false);"
value="Size <%=(rsSelectItem.Fields.Item("Prod_Size").Value)%> @ <%=(rsSelectItem.Fields.Item("Prod_Price").Value)%>
Please, if someone can help me out it would be greatly appreciated!!
Thank you!!