Skip to main content
Inspiring
January 14, 2024
Answered

Uncheck checkbox

  • January 14, 2024
  • 2 replies
  • 974 views

It drives me crazy when the complicated stuff works but the simple stuff doesn't. After detecting that a checkbox was checked under the wrong conditions , I want to display an alert and then uncheck the box.  This javascript runs as part of the actions on the checkbox. Maybe someone out there can help me.

 

This occurs as part of the calculation on the checkbox

 

x=getField("SummerTuition").value
y=getField("AfterCare").value
app.alert("Value of Y is "+y)

if (LOTS OF IRRELEVANT TESTING && y=="Yes")

{
app.alert("You cannot have Extended Care with the "+x+ "Program") // Message appears
event.value="Off" This doesn't work.
}

 

 

This topic has been closed for replies.
Correct answer Thom Parker

Only value based events use "event.value".

For the "MouseUp" use "event.target.value"

 

Is the checkbox where this script is placed named "AfterCare"?  

If it is then replace getField("AfterCare").value with event.target.value

 

 

2 replies

Nesa Nurani
Community Expert
Community Expert
January 15, 2024

This should also not work:

if (LOTS OF IRRELEVANT TESTING && y=="Yes")

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 15, 2024

Only value based events use "event.value".

For the "MouseUp" use "event.target.value"

 

Is the checkbox where this script is placed named "AfterCare"?  

If it is then replace getField("AfterCare").value with event.target.value

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often