- Blogs
- Discussion
- Easy Customized Quiz (radio) Buttons

Intro
For those not familiar with the term, radio-buttons are a group of buttons where only one can be selected and highlighted at a time. They are typically represented as circles and then when selected, filled-in circles.
In Captivate, radio buttons appear on quiz selection and look like this.

Want to create your own buttons with cool shapes and different colours with minimal coding? Keep reading. I’ve included a sample .cptx file as a demonstration.
Step 1: Create the Radio Button
Create a shape – for example a circle. Tick the box ‘use as button’.
Click ‘State View’ and then ‘New State’. Select custom state and title it ‘pressed’. For the new state add another shape or object in the center of your original shape. (For example a check, a smiley face, an ‘x’). If you prefer, delete the ‘rollover’ and ‘down’ views.
Exit state view and name your object ‘button1’
Duplicate this button as many times as you would like on the page.
Step 2: Javascript Programming
Click project -> Variables and create a new variable called ‘last’ with no value.
On enter execute javascript:
window.addEventListener(“mousedown”, function(e) {
if(e.target.id.startsWith(“button”))
{
cp.changeState(last, “Normal”)
last = e.target.id
cp.changeState(last,”pressed”)
}
});
And your done! Now all of your buttons will toggle like radio buttons.
Additional Notes
– The javascript only needs to be executed once per project since it creates a mouse eventListener.
– In the sample document, I had the buttons execute javascript to change a comment variable. The submit button then executes javascript that evaluates this variable.
– The code will work with any object that has an id that starts with ‘button’ and has a state named ‘pressed’
– I know there are many other methods for achieving this. But if you had dozens of buttons, this might simplify the process.
Thanks and if you have any questions please let me know.

Intro
For those not familiar with the term, radio-buttons are a group of buttons where only one can be selected and highlighted at a time. They are typically represented as circles and then when selected, filled-in circles.
In Captivate, radio buttons appear on quiz selection and look like this.

Want to create your own buttons with cool shapes and different colours with minimal coding? Keep reading. I’ve included a sample .cptx file as a demonstration.
Step 1: Create the Radio Button
Create a shape – for example a circle. Tick the box ‘use as button’.
Click ‘State View’ and then ‘New State’. Select custom state and title it ‘pressed’. For the new state add another shape or object in the center of your original shape. (For example a check, a smiley face, an ‘x’). If you prefer, delete the ‘rollover’ and ‘down’ views.
Exit state view and name your object ‘button1’
Duplicate this button as many times as you would like on the page.
Step 2: Javascript Programming
Click project -> Variables and create a new variable called ‘last’ with no value.
On enter execute javascript:
window.addEventListener(“mousedown”, function(e) {
if(e.target.id.startsWith(“button”))
{
cp.changeState(last, “Normal”)
last = e.target.id
cp.changeState(last,”pressed”)
}
});
And your done! Now all of your buttons will toggle like radio buttons.
Additional Notes
– The javascript only needs to be executed once per project since it creates a mouse eventListener.
– In the sample document, I had the buttons execute javascript to change a comment variable. The submit button then executes javascript that evaluates this variable.
– The code will work with any object that has an id that starts with ‘button’ and has a state named ‘pressed’
– I know there are many other methods for achieving this. But if you had dozens of buttons, this might simplify the process.
Thanks and if you have any questions please let me know.
- Most Recent
- Most Relevant
I implemented this in my course using Captivate Classic and it worked perfectly until yesterday. For some reason, the script is no longer changing any of the buttons to the pressed state. I went back to your demo file and it still runs correctly. I decided to check if anything had changed in my course by creating a new project with the same script and objects. Once more, the pressed value isn’t being selected. I am wondering what could have changed between the demo project and the new project and what impact that is having on the script.
I solved the issue. In my haste to streamline my course, I accidentally deleted the last variable. Once I figured out what had happened, it was easy to fix.





