Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

JavaScript message boxes not working

Avatar

Former Community Member

Hi all.  I am Trying to get a few popup messages to work on a form but have not been successful at all. I did this once before and I did work but on this form I have had no luck.  No popup messages work at all and I get no error message.  Please see if you can help with my script.  if(root.P1.matched.Consent.rawValue == 1) {    if(root.P1.client.variable_option_client.cv6.rawValue == null && root.P1.client.variable_option_client.cv7.rawValue == null && root.P1.client.variable_option_client.cv25.rawValue == null)        xfa.host.messageBox("Please enter at least one contact number and select a product from the Product Section.", "Notice", 1);        root.P1.matched.Consent.rawValue = 0 ;    }    else if ((root.P1.client.variable_option_client.cv6.rawValue != null || root.P1.client.variable_option_client.cv7.rawValue != null) && root.P1.client.variable_option_client.cv25.rawValue == null    && root.P1.client.variable_option_client.cv26.rawValue == null && root.P1.client.variable_option_client.cv27.rawValue == null && root.P1.client.variable_option_client.cv28.rawValue == null)    {        xfa.host.messageBox("Please select a product from the Product Section.", "Notice", 1);        root.P1.matched.Consent.rawValue = 0;    }    else if ((root.P1.client.variable_option_client.cv6.rawValue == null && root.P1.client.variable_option_client.cv7.rawValue == null) && root.P1.client.variable_option_client.cv25.rawValue != null)    {        xfa.host.messageBox("Please enter at least one contact number.", "Notice", 1);        root.P1.matched.Consent.rawValue = 0 ;     }             else if ((root.P1.client.variable_option_client.cv6.rawValue != null || root.P1.client.variable_option_client.cv7.rawValue != null) && root.P1.client.variable_option_client.cv25.rawValue != null)    {           root.P1.matched.EmailSubmitButton1.presence = "visible";           root.P1.matched.EmailSubmitButton2.presence = "visible";           // this is event that triggers the script to lock all fields.           //myScriptObject.LockAllFields(root.P1.client.variable_option_client);            //myScriptObject.LockAllFields(root.P1.client.variable_option_client.cv6);                    if (root.P1.client.variable_option_client.DateTimeField1.$.rawValue > "15:00")                 {                    xfa.host.messageBox("The time is after 3pm. Please inform the customer that they are likely to be contacted on the next working day.");        }     }   }    else  {              root.P1.matched.EmailSubmitButton1.presence = "invisible";              root.P1.matched.EmailSubmitButton2.presence = "invisible"; }  Thanks  Joey

7 Replies

Avatar

Level 10

Hi Joey,

The xfa.host.messageBox method has four parameters. The first one (message) is required, whereas the last three are optional. However when you include any of the last three parameters, you need to include all of the three optional parameters.

You are missing one of the last two parameters, either the icon or button types.

When debugging there are two quick checks:

  1. Click the syntac checker button at the top of the Script Editor. This should highlight any lines that have syntax errors.
  2. When previewing the form open the JavaScript Console (Control+J). When interacting with the form, if there are errors these should show up in the console.

Hope that helps,

Niall

Avatar

Former Community Member

Hi Niall,

Can I then remove the ("Notice", 1) from the end of the message box function?

I have run the syntax checker and sorted out one } that was not needed.

If I preview the form and (CTRL-J) nothing happens at all.

Also only thr first popup message appears, the rest dont follow through when making the correct

selections.

Thanks

Joey

Avatar

Level 10

I am away now, so can't check your script.

The if statements are complex, so I suspect that there is something amiss there. Check your relative references and the logic (mixture of !=null and ==null).

You can drop parameters two, three and four.

When you say nothing happens, does the JavaScript Console open?

Niall

Avatar

Level 5

Hi,

I think you are missing a bracket in the code. I have put the bracket where I think it is missing ( made it bold and a little bigger too). Having a look at the logic but it looks alright at first glance.

if(root.P1.matched.Consent.rawValue == 1)

{

if(root.P1.client.variable_option_client.cv6.rawValue == null && root.P1.client.variable_option_client.cv7.rawValue == null && root.P1.client.variable_option_client.cv25.rawValue == null)

{

xfa.host.messageBox("Please enter at least one contact number and select a product from the Product Section.", "Notice", 1);

root.P1.matched.Consent.rawValue = 0 ;

}

else if ((root.P1.client.variable_option_client.cv6.rawValue != null || root.P1.client.variable_option_client.cv7.rawValue != null) && root.P1.client.variable_option_client.cv25.rawValue == null    && root.P1.client.variable_option_client.cv26.rawValue == null && root.P1.client.variable_option_client.cv27.rawValue == null && root.P1.client.variable_option_client.cv28.rawValue == null)

{

xfa.host.messageBox("Please select a product from the Product Section.", "Notice", 1);

root.P1.matched.Consent.rawValue = 0;

}

else if ((root.P1.client.variable_option_client.cv6.rawValue == null && root.P1.client.variable_option_client.cv7.rawValue == null) && root.P1.client.variable_option_client.cv25.rawValue != null)

{

xfa.host.messageBox("Please enter at least one contact number.", "Notice", 1);

root.P1.matched.Consent.rawValue = 0 ;

}

else if ((root.P1.client.variable_option_client.cv6.rawValue != null || root.P1.client.variable_option_client.cv7.rawValue != null) && root.P1.client.variable_option_client.cv25.rawValue != null)

{

root.P1.matched.EmailSubmitButton1.presence = "visible";

root.P1.matched.EmailSubmitButton2.presence = "visible";           // this is event that triggers the script to lock all fields.         

//myScrip tObject.LockAllFields(root.P1.client.variable_option_client);            //myScrip tObject.LockAllFields(root.P1.client.variable_option_client.cv6);                    if (root.P1.client.variable_option_client.DateTimeField1.$.rawValue > "15:00")

{

xfa.host.messageBox("The time is after 3pm. Please inform the customer that they are likely to be contacted on the next working day.");

}

}

}

else

{

root.P1.m atched.EmailSubmitButton1.presence = "invisible";              root.P1.m atched.EmailSubmitButton2.presence = "invisible";

}

Regards

Malcolm

Avatar

Former Community Member

Hi Malcom,  That has definitely helped. I have put in the extra bracket and the code runs.  Now I need to get the submit buttons to appear if the right selections are made. This is not happening at present even if the right fields have the correct data.  Joey

Avatar

Level 1

Hello Everyone,

In Java Script there are two types of message box for displaying information. One is known as “alert” and another one is known as “confirm”. If you want to display an alert or warning regarding programs then we use alert () method for displaying message box and if we want to take some confirmation from user then we use confirm () method for displaying message box........

Please check out the this link for more details....

http://mindstick.com/Articles/58db4d3d-8d46-463b-a826-ce75de52d03c/?Displaying%20a%20message%20box%2...

Thanks !!!!!

Avatar

Level 10

I don't believe that works in LiveCycle.

This group is for LiveCycle Designer, it's not the same as programming for browsers.