I have three comboboxes A, B and C with one item each 1, 2 and 3 wich all trigger the "printAscend" function. How do I make the variable "x" switch place with the variable that coresponds the combobox that triggerd the function. Ex: if I select an item from combobox "C" I want the last line change to console.println(a + b + x); and they always have to be in the same order.
function printAscend(){
var a = this.getField("A").value;
var b = this.getField("B").value;
var c = this.getField("C").value;
var x = event.changeEx;
if(!event.willCommit){
console.println(a + b + c);
}
}
I have some solutions but I don't like them, I'd like to see how you do it.
Ex:
if(event.changeEx = "1"){
console.println(x + b + c);
}
else if(event.changeEx = "2"){
and so on...
(tabs vanished from the script when submitted?)
function printAscend() {
var fa = getField("A");
var fb = getField("B");
var fc = getField("C");
var ft = event.target;
var a = ft === fa ? event.changeEx : fa.value;
var b = ft === fb ? event.changeEx : fb.value;
var c = ft === fc ? event.changeEx : fc.value;
if(!event.willCommit){
console.println(a + b + c);
}
}
But you may need to convert the field values to number or strings, depending on whether you want string concatenation or numerical addition.