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

Visibility of a Text Box Based on Value in a TextField

pforms
Registered: Nov 17 2009
Posts: 87
Answered

Based upon a score entered in a TextField, I'm trying to get a text box to appear.
 
Trying this and it may not be the best solution:
text box set to hidden
javascript on the exit event of the TextField
 
if(this.rawValue=7)
textbox1.presence="visible";

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

try this script in the change:Event of your text field:
textbox1.presence = xfa.event.newText === 7? "visible":hidden";

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

pforms
Registered: Nov 17 2009
Posts: 87
Can't get that to work; Playing with this:

--- form1.#subform[0].CITotal::exit - (JavaScript, client)

if(this.rawValue=="7")
Frame.presence="visible"
else
Frame.presence="hidden"

----- form1.#subform[0].CITotal::calculate - (FormCalc, client) ------------------------------------

Sum(CI[*])

-----------------------------------------------------------------

Frame is a hidden text field

Oddly, it works if I click back into one of the scoring fields


radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You have to use xfa.event.newText instead of rawValue to change the visibility during the text entry.
The rawValue will be applied only after you exited the field.

Btw. The first code had a typo. Try again with this in the change:Event.
Frame.presence = xfa.event.newText === "7"? "visible":"hidden";

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

pforms
Registered: Nov 17 2009
Posts: 87
Using your script, here's what I have:

Four text fields:
Score[0]
Score[1]
Total
Frame (hidden)

one text box with the word HIGH

The text box is layered behind Frame

Scripts on Total:
---- form1.#subform[0].total::calculate - (FormCalc, client) --------------------------------------

Sum(score[*])

----- form1.#subform[0].total::change - (JavaScript, client) ---------------------------------------

Frame.presence = xfa.event.newText === "7"? "visible":"hidden";

Thanks for the help as this is confusing me to no end
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Ok,

you use numeric fields instead text fields, so the solution is a bit different.
  1. form1.#subform[0].total::calculate - (FormCalc, client)
  2. var s = Sum(Score[*])
  3. $ = s
  4.  
  5. if (s eq 7) then
  6. Frame.presence = "visible"
  7. else
  8. Frame.presence = "hidden"
  9. endif

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

pforms
Registered: Nov 17 2009
Posts: 87
The change event was throwing it off. "Validate" worked