JavaScript Help

Associate
Joined
13 Jul 2009
Posts
1,133
Location
Cambs
I have the following calculation:

if (this.getField("CB-Acrobatic").value=="3" &&
this.getField("Acrobatics-Ranks").value>9) {
event.value = 4;
} or
else event.value = "0";

But I also want it to check the following:

if (this.getField("CB-Acrobatic").value=="3" &&
this.getField("Acrobatics-Ranks").value<9) {
event.value = 2;
} or
else event.value = "0";

How would I go about combining these two calculations into one tidy script?

Also can anyone recommend a decent book to learn javascript from?
 
Else if is your friend :)

Code:
var cbAerobatic = ParseInt(this.getField("CB-Acrobatic").value);
var aerobaticRanks = ParseInt(this.getField("Acrobatics-Ranks").value);

if (cbAerobatic==3 && aerobaticRanks > 9) {
	event.value = 4;
} 
else if (cbAerobatic==3 && aerobaticRanks < 9) {
	event.value = 2;
} else {
	event.value = 0;
}
 
I adapted it for use with adobe but it worked fab, ty.
Code:
if (this.getField("CB-Acrobatic").value=="3" && this.getField("Acrobatics-Ranks").value>9) {
		event.value = 4;
	} else if (this.getField("CB-Acrobatic").value=="3" && this.getField("Acrobatics-Ranks").value<9) {
		event.value = 2;
	} else event.value = "0";

Do you know if it is possible to change the font colour of a text box via a checkbox script of somekind?

So if I want something like,

if checkbox1=1 then textbox1.forecolor=red
else textbox1.forecolor=black :confused:
 
Back
Top Bottom