Expand my Community achievements bar.

SOLVED

Event change - Why is doesn't select the current value, just the value previous?

Avatar

Level 4

Hi.

I am using the script that when the user select some value on the drop-down box, a object Text visible (using the "presence")

I am using the event change, but it doesn't work very well. When I select a value, it doesn't change the Text, but if I select another value, it appear the value selected previous.

Why doesn't it Synchronize the value?

Thanks!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Rafael,

I am not sure if you are using a good event.

mouseExit is a good event to use (particularly when paired with mouseEnter), when changing the visual appearance of an object. For example a button where the caption is underlined on mouseEnter and not underlined on mouseExit.

If you want to change the presence of objects on the form as the user hovers over the dropdown, then mouseEnter/mouseExit should work. However if you want the changes to happen once the user selects an item from the dropdown, I would recommend the exit event.

Here are some examples:

https://acrobat.com/#d=txGF4IAoqmfTKPrLkwybIA

https://acrobat.com/#d=OzNofi-xFxmpXD1MrVU6rA

https://acrobat.com/#d=Hi0ZwVgVB1PWbxc6OJ0z4A

Hope these help,

Niall

Assure Dynamics

View solution in original post

6 Replies

Avatar

Level 10

Hi,

The best way I can explain it, is that the change event fires before the selected item is committed to the dropdown object's rawValue.

When scripting in the change event you need to use the xfa.event.newText, instead of .rawValue. You script should work okay then. However you could just move it as it is to the exit event (as the selected item is committed at that stage) and it should work.

Summary:

Change event - use xfa.event.newText

All other events - use .rawValue

Niall

Avatar

Level 4

Hi Niall.

Thanks for you fast reply.

So, I am developing this following way:

if(this.rawValue == 1){

texto_apresentacaos.presence = "visible";

texto_noticias.presence = "hidden";

texto_comentarios.presence = "hidden";

}

if(this.rawValue == 2){

texto_apresentacaos.presence = "hidden";

texto_noticias.presence = "visible";

texto_comentarios.presence = "hidden";

}

if(this.rawValue == 3){

texto_apresentacaos.presence = "hidden";

texto_noticias.presence = "hidden";

texto_comentarios.presence = "visible";

}

How Can I use your solution? I tryed to change the rawValue to xfa.event.newText, but it didn't work.

Example:

if(this.xfa.event.newText == 1){

texto_apresentacaos.presence = "visible";

texto_noticias.presence = "hidden";

texto_comentarios.presence = "hidden";

}

Sorry If I am doing wrong.

Avatar

Level 10

Hi Rafael,

If you place the script in the exit event and delete all of the script in the change event. The following Javascript in the exit event should work:

// first I would hide all of the objects

texto_apresentacaos.presence = "hidden";

texto_noticias.presence = "hidden";

texto_comentarios.presence = "hidden";

// then I would use an if/else statement

if (this.rawValue == 1)

{

     texto_apresentacaos.presence = "visible";

}

else if (this.rawValue == 2)

{

     texto_noticias.presence = "visible";

}

else if (this.rawValue == 3)

{

     texto_comentarios.presence = "visible";

}

Things to check:

  • That the dropdown and the three texto objects are in the same subform. If not, you will need a fuller reference to the texto objects.
  • That in the dropdown you have ticked specified values in the Object > Binding tab and that the three choices have specified values of 1, 2 and 3.
  • That the form is saved as a Dynamic XML Form in the save-as dialog.

LC SaveAs Dialog.png

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 4

Hey Niall.

Thanks for reply.

Actually I was already sing the propriety "mouseExit". It works very well, but the single problem is that the runtime (change of the propriety presence) isn't immediately however using the event change is immediately.

For my problem really the single way is using the event Mouseexit?

Thanks!

Avatar

Correct answer by
Level 10

Hi Rafael,

I am not sure if you are using a good event.

mouseExit is a good event to use (particularly when paired with mouseEnter), when changing the visual appearance of an object. For example a button where the caption is underlined on mouseEnter and not underlined on mouseExit.

If you want to change the presence of objects on the form as the user hovers over the dropdown, then mouseEnter/mouseExit should work. However if you want the changes to happen once the user selects an item from the dropdown, I would recommend the exit event.

Here are some examples:

https://acrobat.com/#d=txGF4IAoqmfTKPrLkwybIA

https://acrobat.com/#d=OzNofi-xFxmpXD1MrVU6rA

https://acrobat.com/#d=Hi0ZwVgVB1PWbxc6OJ0z4A

Hope these help,

Niall

Assure Dynamics

Avatar

Level 4

Hi Niall!

You are excellent!!

Using the exit event works very very well

I don't have words to thank you for all these helps!

Thanks so much Niall!

Have a nice day!

Correct Reply and Helpfull answer!