Expand my Community achievements bar.

Tricky Text Box

Avatar

Former Community Member

I am creating a text box that will auto fill based on certain conditions. In this example, I would like a certain message to appear if US selected from my dropdown. If UK is selected, I would like the first message to dissapear and have a second message appear. Vice versa if the user selects UK, then US.

Here is the script:


Change Event for the dropdown

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;}

Form:ready Event for the dropdown

txtReminder.rawValue = txtVar.rawValue;

Initialize Event for txtVar

this.rawValue = txtReminder.rawValue

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 a hidden text box.

Let me know if this requires anymore clarification, Thanks!!

1 Reply

Avatar

Level 6

Already replied to old post any how here is the code block have to use.

in if else loops no need to get same value couple of times get one time and use it where ever required in the same scope. compare the code you will find what went wrong with old code.

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.