Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript "show", CP8

Engaged ,
May 24, 2015 May 24, 2015

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

5.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , May 25, 2015 May 25, 2015

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

Translate
Engaged ,
May 24, 2015 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 24, 2015 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 24, 2015 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 24, 2015 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 24, 2015 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");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 24, 2015 May 24, 2015

For whatever reason, I just can't get it to work. I am able to confirm the parameter is coming over (i.e. "which" in the above example) but it seems the cp.show is not executing for some reason. For example, if I put an alert(which) in the function, the Alert pops up with the value of which in it. So I know the function works and is getting the info passed to it.

I am starting the items as "Not visible in output" if that makes a difference.

Any other thoughts?

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 24, 2015 May 24, 2015

Couldn't say for sure. This is html5 output, yes?

It's never not worked for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 24, 2015 May 24, 2015

Yes, I am editing the .htm file that is outputted after publishing.

Thanks for all your help.

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 25, 2015 May 25, 2015

What I meant was HTML5, not the html that inserts the swf, This doesn't work with swf.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2015 May 25, 2015

I've been editing the created .htm file with the JS and previewing with Safari. Isn't that the right file to be adding the code to?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2015 May 25, 2015

a.gif

Sem título.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2015 May 25, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2015 May 25, 2015
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources