This can be achieved by writing an expression like this.value = (TextField1.value ==1) * 2 . However if your case is so complex that you cannot derive an expression relating the fields then you can write a service, make an ajax call to it passing the value of TextField1, and return desired value of the field via service and assign the responseText of the field to the value in the calculate expression like
Let's say this in your example point to field2 for which you want to write calculate expression. Open the propertiies(or edit) dialog of field2 in edit mode and in Calculate Expression input box, enter expression:
( TextField1.value == 1) ? 2 : 0
That is exactly what I expect. When I copy the code you sent in your earlier post and paste it in my last name calculate expression field, I don't get any values for charles, susan or tim. Could there be an error in the code I'm pasting? please see code below.
This works for me. It gives me "john" in the other field if it inscribe "charles" in the field firstname , "morris" for "susan", "michaels" for "tim" and nothing for any other value. Is it not what you are expecting?
I'm wondering if it is possible to have an expression like ( firstname.value == "charles" ) ? "John" : " "; ( firstname.value == "susan" ) ? "morris" : " "; ( firstname.value == "tim" ) ? "michaels" : " "; in my last field calculate expression?
At the moment, it only works correctly for the first expression set i.e. charles but dosen't work for any of the rest.