Skip to main content
Known Participant
Aug 17, 2017 9:08 AM UTC
Answered

Help Needed Please

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.

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Aug 17, 2017 1:28 PM UTC

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


Use this:

Quant.value = this.getField("Qty." + added).value;

9 replies

Bernd Alheit
Community Expert
Community Expert
Aug 17, 2017 9:54 AM UTC

What code do you use at the button?

Translate
Known Participant
Aug 17, 2017 10:03 AM UTC

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

}

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 17, 2017 10:13 AM UTC

You must change following line:

Quant.value = "0";

Quant.value = ... insert here the value of the field ... ;

Translate