Copy link to clipboard
Copied
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
Send me the demo file Dave, andrepazleal@gmail.com.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Couldn't say for sure. This is html5 output, yes?
It's never not worked for me.
Copy link to clipboard
Copied
Yes, I am editing the .htm file that is outputted after publishing.
Thanks for all your help.
Dave
Copy link to clipboard
Copied
What I meant was HTML5, not the html that inserts the swf, This doesn't work with swf.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Send me the demo file Dave, andrepazleal@gmail.com.