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

Javascript for Conditional Message

publicdebter
Registered: Feb 20 2008
Posts: 18
Answered

Can anyone provide script for the following please:

I would to have three different messages in hidden fields.

Based on the value that is calculated in a certain text box, one of the three messages would be shown.

For example, if the sum is less than 300, then message 1 would appear.

If the sum equals 300 to 499, then message 2 would appear.

If the sum is 500 or greater, then message 3 would appear.

Can anyone help? Thanks!

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Both Acrobat forms and LiveCycle Designer have various conditional stamens including the "if then else" statement and field properties to show or hide other form fields. The syntax of the statement varies with the product and language.

Acrobat forms JavaScript only for the field with the sum:

// hide all fields
this.getField("Message1").display = display.hidden;
this.getField("Message2").display = display.hidden;
this.getField("Message3").display = display.hidden;

if (event.value < 300) {
this.getField("Message1").display = display.visible;
}
if (event.value >= 300 & event.value < 500) {
this.getField("Message2").display = display.visible;
}
if (event.value >=500) {
this.getField("Message3").display = display.visible;
}LiveCycle Designer FormCalc:

Message1.presence = "invisible"
Message2.presence = "invisible"
Message3.presence = "invisible"

if ($.rawValue < 300) then
Message1.presence = "invisible"
endif

if ($.rawValue >= 300 and $.rawValue < 500) then
Message2.presence = "invisible"
endif

if ($.rawValue > 500) then
Message3.presence = "invisible"
endif

LiveCycle Designer JavaScript:

// hide all fields
Message1.presence = "invisible";
Message2.presence = "invisible";
Message3.presence = "invisible";

if ($.rawValue < 300) {
Message1.presence = "visible";
}
if ($.rawValue >= 300 & event.value < 500) {
Message2.presence = "visible";
}
if ($.rawValue >=500) {
Message3.presence = "visible";
}

George Kaiser