Copy link to clipboard
Copied
I try create catalogue with buy option and i stuck on the one thing I need to create java script which after clicking on add to cart button will transfer Qty (filed by customer) to last page where is order .At the moment when customer click on cart code, product description and price are transferred just stuck on Qty.
Use this:
Quant.value = this.getField("Qty." + added).value;
Copy link to clipboard
Copied
I try create catalogue with buy option and i stuck on the one thing I need to create java script which after clicking on add to cart button will transfer Qty (filed by customer) to last page where is order .At the moment when customer click on cart code, product description and price are transferred just stuck on Qty.
Use this:
Quant.value = this.getField("Qty." + added).value;
Copy link to clipboard
Copied
What code do you use at the button?
Copy link to clipboard
Copied
This is code for Button
var thename = this.getField(event.target.name);
N = thename.name.substring(4,thename.name.length);
AddToCart(N);
And add to cart function is
function AddToCart(added)
{
this.calculate = false;
var lstItemNum = this.getField("lstItemNum")
var lstItem = this.getField("lstItem")
var lstPrice = this.getField("lstPrice")
IName = lstItem.getItemAt(added-1)
/* original script
var NI = this.getField("TotalNumItems");
NI.value = NI.value+1
var Dest = this.getField("Description."+NI.value)
var INum = this.getField("INum."+NI.value)
var UPrice = this.getField("UPrice."+NI.value)
var Quant = this.getField("Quantity."+NI.value)
var TPrice = this.getField("TPrice."+NI.value)
Dest.value = IName
INum.value = lstItemNum.getItemAt(added-1)
UPrice.value = lstPrice.getItemAt(added-1)
Quant.value = "1"
TPrice.hidden = false
*/
// corrected script
{
var NI = this.getField("TotalNumItems");
NI.value = NI.value+1
var Dest = this.getField("Description."+NI.value)
var INum = this.getField("INum."+NI.value)
var UPrice = this.getField("UPrice."+NI.value)
var Quant = this.getField("Quantity."+NI.value)
var TPrice = this.getField("TPrice."+NI.value)
Dest.value = IName
INum.value = lstItemNum.getItemAt(added-1)
UPrice.value = lstPrice.getItemAt(added-1)
Quant.value = "0"
TPrice.hidden = false
}
// end correction
this.calculate = true
}
Copy link to clipboard
Copied
You must change following line:
Quant.value = "0";
Quant.value = ... insert here the value of the field ... ;
Copy link to clipboard
Copied
But this can be filled out by customer and can be any number they put in this field
Copy link to clipboard
Copied
Yes, take the value of the field:
this.getField(" field name ").value;
Copy link to clipboard
Copied
That is what i mean but more tricky part is when they press buy.1 should show Qty.1 but when buy.2 Qty.2 etc. Any idea you was so helpful Thanks
Copy link to clipboard
Copied
Different script for each field
Copy link to clipboard
Copied
Use this:
Quant.value = this.getField("Qty." + added).value;
Copy link to clipboard
Copied
Thank you very much