Skip to main content
Inspiring
May 24, 2015
Answered

Javascript "show", CP8

  • May 24, 2015
  • 2 replies
  • 5756 views

I am using Javascript for the On Enter Action to run some XML code. I also need to use the show / hide of an Object as well. Is there any code I can use to control the presence of an object?

I saw a previous post to use cp.show("image"); but that doesn't seem to work.

Thanks.

Dave

    This topic has been closed for replies.
    Correct answer andreleal

    That's how I have it set but it's not working. Can you show me the JS code you are adding to make it work?

    Thanks.

    Dave


    Send me the demo file Dave, andrepazleal@gmail.com.

    2 replies

    TLCMediaDesign
    Inspiring
    May 24, 2015

    To show you need to put the name of the image or object as shown at the top of the properties panel.

    I use shows all the time in JS and it always works. The following is used to show a next button based on the current slide. The button is named  "next_1" and so on.

    cp.show("next_"+window.cpInfoCurrentSlide);

    Inspiring
    May 24, 2015

    Hmmm...just as a basic setup to test, I created 2 buttons btn5 & btn6 (set to not visible). I set btn5 for Action, On Success to "Execute Javascript". In the script window I put cp.show("btn6");

    Nothing happens...I don't see btn6.

    Any thoughts?

    Thanks.

    TLCMediaDesign
    Inspiring
    May 24, 2015

    You need to put the function in the html page. If you try to execute from the script window cp will be undefined.

    I have a custom js file that I put all of the functions in and have it included in the templates.

    You don't have to republish to test your scripts. Put this in the head section:

    <script>

    function showItem(which)

    {

    cp.show(which);

    }

    </script>

    Then in CP, execute JS:

    showItem("btn6");

    Inspiring
    May 24, 2015

    To continue...I know you can get, set variable with JS but is there anyway to call Advanced Actions through JS?

    In the reference document, it doesn't show anything in regards to show/hide or advanced actions.

    Thanks.

    Dave

    TLCMediaDesign
    Inspiring
    May 24, 2015

    Technically there are no actual advanced actions in the output. Just a compilation of the elements that make up the advanced action.

    For example if you have an advanced action called "check20" in Captivate, there is no reference to check20 in the output.