These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Can someone please take a look this code

dbertanjoli
Registered: Nov 18 2007
Posts: 30

Values from price field are copied to the quantity field I am not sure why?

[,,]
var oAssemblyParts = {
Chasis: [ ["-","None","none"], ["Rear Bracket","205.95","one"], ["Front Bracket",185.95,two], ["Long Support","44.95","three"],["Front Bearing","48.95","four"]],

function SetPartEntries()
{
// Only run this code on when the selection is commited.
if(event.willCommit)
{
// There are 3 rows in the order form so in order to use other fields in
// the same row we first have to acquire the name of the row
// we are operating on. This is part of the List field's name, so we
// just have to split it off
var cRowName = event.target.name.split(".").shift();

// Now get the new parts list from the Master List
// Since the selection is being committed, event.value contains the selection text
var lst = oAssemblyParts[event.value];
// If an entry is selected that we don't have a parts list for, then
// the parts list is just cleared.
if( (lst != null) && (lst.length > 0) )
this.getField(cRowName + ".PartSelect").setItems(lst);
else
{
this.getField(cRowName + ".PartSelect").clearItems();
}

// We have a new parts lists and the first entry is
// is a non-selection. so clear the price field.
this.getField(cRowName + ".Price").value = 0;
this.getField(cRowName + ".Quantity").value = 0;
}
}

////////////////
// SetPriceValue()
//
// Function for setting the price value based on the Parts selection value
//
// This function is specifically setup to be called from the Change Event
// of the Parts List. It will not work from another event because the
// "event.willCommit" and "event.changeEx" parameters are used
//
function SetPriceValue()
{
// Only run this code on the un-committed change. This fields is set up
// for Commit on select so we know the value will be committed
if(!event.willCommit)
{
var cRowName = event.target.name.split(".").shift();

// If the export value is Not a Number then
// set the price to zero.
var nSelExp = 0;
if(!isNaN(event.changeEx))
nSelExp = event.changeEx

this.getField(cRowName + ".Price").value = nSelExp;

}
}

////////////////
// SetQuantityValue()
//
// Function for setting the price value based on the Parts selection value
//
// This function is specifically setup to be called from the Change Event
// of the Parts List. It will not work from another event because the
// "event.willCommit" and "event.changeEx" parameters are used
//
function SetQuantityValue()
{
// Only run this code on the un-committed change. This fields is set up
// for Commit on select so we know the value will be committed
if(!event.willCommit)
{
var cRowName = event.target.name.split(".").shift();

// If the export value is Not a Number then
// set the price to zero.
var nSelExpQ = 0;
if(!isNaN(event.changeEx))
nSelExpQ = event.changeEx

this.getField(cRowName + ".Quantity").value = nSelExpQ;

}

}

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
It appears you are trying to do what is shown here:

Changing Another Field with Combo Box (Drop Down) Selection, http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/change_another_field/ .

George Kaiser