1 Reply Latest reply on Sep 27, 2012 8:22 AM by sarbarker

    Timing issue with Javascript and ActionScript setting/getting variable

    sarbarker Level 1

      Hi everyone,

       

      The Course

       

      I have created a training course, that will be running standalone on our intranet for internal staff. Despite the (known) limitations, I am using Javascript to validate the form and open an email window, for the staff member to click Send to confirm they have completed the course. Without a web server or LMS to use, this seems the simplest way to get confirmation of course completion. The form itself works fine and we have tested it with some staff.

       

      I have created a slide in Captivate that contains the confirmation form with a Submit button. I have added a Next button, which appears disabled until the user submits the form successfully.

       

      The Problem

       

      When the user clicks Submit, I call a Conditional Action as follows:

      • If 1 = 1 (i.e. always do this)
        • Call Javascript to:
          • Validate the form
          • If valid
            • Open the email window
            • Set m_VarHandle.Confirmation_Email = 1
      • If Confirmation_Email = 1
        • Enable Next button

       

       

      Unfortunately, when completing the form correctly and clicking Submit, the Next button is not enabled (clicking again enables the button fine). On further testing, it seems that the Javascript has not completed executing before ActionScript moves onto the next Decision. So, when it checks the value for Confirmation_Email it has not yet been set and the Next button is not enabled.

       

      Any ideas how I can overcome this problem?

       

      Thanks

      Sarah.

        • 1. Re: Timing issue with Javascript and ActionScript setting/getting variable
          sarbarker Level 1

          Hi everyone

           

          I have worked around this problem as follows.

           

          • Added a Clickbox that appears for 0.5 seconds with a pause
          • Created a disabled Next button that is visible in output and appears for 0.8 seconds
          • Updated the timeline so that the (enabled) Next button appears after 0.8 seconds for the rest of the slide
          • Added a second Clickbox that appears at 1.0 second with a pause at the end of the slide (2.0 seconds)
          • Updated the Javascript to set cpCmndResume to 1 when the form is successfully validated

           

          This leads to the desired behaviour:

          • The slide plays up to 0.5 seconds and pauses due to the first Clickbox
          • The user can fill out the form at their leisure and Submit.
            • If validation fails, the user must correct the form and click Submit
            • If validation passes, playback is resumed
          • When playback is resumed, it runs past the 0.8 second mark. The disabled Next button disappears and the enabled Next button appears. Playback continues until the 2.0 second mark then pauses due to the second Clickbox
          • The user can click Next at their leisure

           

          Thanks for all the reads - hope this is helpful!

           

          Cheers

          Sarah.