Expand my Community achievements bar.

SOLVED

DropDown Menu Script Question

Avatar

Former Community Member

Real Simple, if "United States" is chosen on my dropdown, I would like a certain textbox to dissappear. I have tried all of these syntax, but nothing will work, please help:

if(xfa.event.newTexT == 'United States'){
txtTempID.presence = "hidden";
}

or

if(this == 'United States'){
txtTempID.presence = "hidden";

}

or

if(this.rawVaule == 'United States'){
txtTempID.presence = "hidden";
}

or

if(this.rawVaule == '134'){
txtTempID.presence = "hidden";
}

None of these worked, btw United States has a value of "134" on my dropdown list. Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Change the line of code to say

txtbox.rawValue = txtbox.rawValue + "PLEASE READ!!!"}

Paul

View solution in original post

10 Replies

Avatar

Level 6

if(xfa.event.newText == "United States"){
txtTempID.presence = "hidden";
}

OR


if(this.rawValue == '134'){
txtTempID.presence = "hidden";
}

Both of the ways it will work. But for this form should save as dynamic pdf Form type.

RAGHU.

Avatar

Former Community Member

Hey I have a followup question:

if(this.rawValue =='1'){
subformUS1.presence = "hidden";
txtbox.rawValue = "PLEASE READ!!!"}

This will populate the txtbox with the words "PLEASE READ!!!". However, anything else that I have currently written in that text box is erased. Is it possible to add the words "PLEASE READ!!!" to my text box, instead of replacing it? thanks!!

Avatar

Correct answer by
Former Community Member

Change the line of code to say

txtbox.rawValue = txtbox.rawValue + "PLEASE READ!!!"}

Paul

Avatar

Level 6

If that check box clicks only one time that would be fine,  if not it will keep on add those values again and again.

Lets assume

Hidden field as - TextField3

your text field which need changes in text as - txtbox

here is the code.

First assign TextField3 value as txtbox initial value.

On form ready event assign the hidden field value to ur text field.

txtbox.rawValue = TextField3.rawValue;

on change event ur code like this

var oldV = TextField3.rawValue;
if(this.rawValue =='1'){
subformUS1.presence = "hidden";
txtbox.rawValue = oldV + "PLEASE READ!!!";
}else{
txtbox.rawValue = oldV;
}

RAGHU.

Avatar

Former Community Member

I know this question has been answered, but I have a quick followup question. When adding additional text to my textbox, I would also like it to go to the next line. I used "/n", but I'm not sure if that's correct. How would I get it to skip a line, then add the new text? Thanks

Avatar

Level 6

use "\n" to start in new line. Any text after this newline character ("\n") will be displayed in the next line.

Avatar

Former Community Member

As always, you've been a big help. Thanks Raghu

Avatar

Former Community Member

Hey, I had another followup question. I followed Raghu's instructions from before, but I encountered a problem:

var oldV = txtVar.rawValue;
if(xfa.event.newText == "US"){
txtReminder.rawValue = oldV + "\n ALERT #1."}
else{txtReminder.rawValue = oldV;}

var oldV = txtVar.rawValue;
if(xfa.event.newText == "UK"){
txtReminder.rawValue = oldV + "\n ALERT #2."}
else{txtReminder.rawValue = oldV;}

Everytime UK is selected in my dropdown, "ALERT #2" appears, and then disappears if another option is selected (this is exactly what I want). However, nothing happens when US is selected. When I delete the second script block (the UK one), the US selection now works. Please advise on how I can get both to work.

txtReminder is the text box that is being modified

txtVar is the hidden text box.

Avatar

Level 6

Problem with the code u have written, its having repeated blocks of same code, use it in this way.

var oldV = txtVar.rawValue;

if(xfa.event.newText == "US"){

txtReminder.rawValue = oldV + "\n ALERT #1."}

else if(xfa.event.newText == "UK"){

txtReminder.rawValue = oldV + "\n ALERT #2."}

else{txtReminder.rawValue = oldV;}

RAGHU.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----