Hey,
I have a combobox and radio buttons with specific prices that I want attached depending on the choice the user makes. I’m having trouble getting the application to add the total of the selections and display the total in a dynamic textbox.
I am trying to use global variables. I set them to a certain value depending on what is selected. At the end I set add them up in the variable total and set that equal to the text box named totalPrice.
Right now the value of the global variables is not being returned from their functions.
Any suggestions for how to do this correctly? I have attached the fla in a zip file. Below is the code if you’d rather just look at that.
Thanks!
//combo box
//create new listener to check for a change in combobox
objComboListener = new Object();
objComboListener.change = function(eventObj){
//create variable to get comboboxes label and check to see if it's "Please Select"
//get the data value of selected item and set global variable to a price
var number=sizeBox.getSelectedItem().data;
if(number==0){
_global.collarSize = 0;
return _global.collarSize;
} else if (number==1){
_global.collarSize = 10.00;
return _global.collarSize;
} else if (number==2){
_global.collarSize = 15.00;
return _global.collarSize;
} else if (number==3){
_global.collarSize = 20.00;
return _global.collarSize;
}
}
//call the change function
sizeBox.addEventListener("change", objComboListener);
//personalize yes or no
//create a new listening object and create a function for it
personListener = new Object();
personListener.click = function (evt){
//get the label for an item and set variables to a price
person = evt.target.selection.label;
if (person=="Side") {
_global.side = 7.00;
_global.center=0;
return _global.center;
return _global.side;
}else if (person=="Center") {
_global.side=0;
_global.center = 8.00;
return _global.center;
return _global.side;
}else {
_global.side=10;
_global.center=0;
return _global.center;
return _global.side;
}
}
//call the personalize function
Personalize.addEventListener("click", personListener);
//add the global variables and put them into total
_global.total = _global.collarSize + _global.center + _global.side;
//display results in dynamic text box next to "Price:"
price.totalPrice.text=_global.total;