# Adding Javascript to boxes and buttons

You can add JavaScript to click boxes, text entry boxes, and buttons in Captivate projects. The JavaScript can run when a user clicks inside or outside the box or button. Using JavaScript gives you the opportunity to extend movies in numerous ways while adding interactivity.

You can add JavaScript when you create a new box or button, or add JavaScript to an existing box or button.

#### To add JavaScript to a new box or button:

1. Open a Captivate project.

2. Double-click the slide to which you want to add a box or button with JavaScript.

3. From the Insert menu, select Click Box, Text Entry Box, or Button.

4. In either On success (for if the user clicks inside the click box) or After last attempt (for if the user clicks outside the click box), select the Execute JavaScript option.

5. Click More.

The JavaScript dialog box appears.

6. Enter your JavaScript code in the text box. If you have the JavaScript in another location, you can copy it and paste it into the text box.

7. Click OK.

8. Click OK again.

#### To add JavaScript to an existing box or button:

1. Open a Captivate project.

2. Double-click the slide containing the box or button to which you want to add JavaScript.

3. Double-click the box or button to which you want to add JavaScript.

4. In either On success (for if the user clicks inside the click box) or After last attempt (for if the user clicks outside the click box), select the Execute JavaScript option.

5. Click More.

The JavaScript dialog box appears.

6. Enter your JavaScript code in the text box. If you have the JavaScript in another location, you can copy it and paste it into the text box.

7. Click OK.

8. Click OK again.