Copy link to clipboard
Copied
CP9
Hello,
I have a SmartShape called DOCTOR being used as a button.
I want to 'Press' this button using some external JavaScript.
I used to know how to do this, but I've had a break from CP for quite a while and I have forgotten.
Thank you.
Peter.
Found it.
This appears to work.
The window.parent.cp.clickHandler(DOCTOR); is the JavaScript.
To execute it from the PHP it has to be echoed.
echo "<script type='text/javascript'>window.parent.cp.clickHandler(DOCTOR);</script>" ;
Hope that helps anyone else.
Copy link to clipboard
Copied
Why with JS? What is the purpose please? In my mind a button (shape or old type) is meant to be pressed by the learner, and to trigger something to happen which is the core of interactivity. Why would you use JS? Even a JS script has to be triggered by an event. It is only since a while that a 'Delay Next actions...' was added which allows to delay the 'happening' of the actions when an event occurs.
Please chack the version type you are using, it should be 9.0.2.
Copy link to clipboard
Copied
CP 9.0.2.437
Liliybiri,
Version CP 9.0.2.437
I appreciate your interest in why I want to use JS to press a button.
I did not include the full explanation in the original question as that would only have complicated the question.
However, to answer you fully...
I have an HTML form displayed in a WebObject on a Captivate page.
The HTML form takes input from the user.
The input is passed to a PHP script that locates and and validates the user input in our company Active Directory of users using LDAP and extracts related information from it.
Based on the extracted information the PHP executes some JavaScript to carry out actions in the Captivate project, such as setting variables, hiding/showing items and jumping to certain slides, plus some none Captivate tasks such as recording activity in a database and sending an email.
The Captivate file already has a DOCTOR button that performs a particular set of actions, and I would like these actions to be run as part of the JavaScript that is executed the PHP file.
However, rather than recreating the function of the existing Captivate DOCTOR button in JavaScript it would be much easier to just Press the button from the JavaScript in the PHP.
I hope the above helps to explain why I asked the original question.
Thank you
Peter.
Copy link to clipboard
Copied
That makes sense, thanks for the explanation!
Copy link to clipboard
Copied
Found it.
This appears to work.
The window.parent.cp.clickHandler(DOCTOR); is the JavaScript.
To execute it from the PHP it has to be echoed.
echo "<script type='text/javascript'>window.parent.cp.clickHandler(DOCTOR);</script>" ;
Hope that helps anyone else.