Create mutually exclusive checkboxes in "dat GUI" api.

The problem : I want only one checkbox to be selected at a time. I want it to work same as radio buttons.
 Note : dat gui does not offer radio buttons.

Please download stats.min.js from attachment.

jsp page :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="abc.js"></script>
<script type="text/javascript" src="dat.gui.min.js"></script>

<body onload="gui();">


Open in new window

javscript page: "abc.js"
var gui_control = function () {


function gui()
var gui_controls=new gui_control();
var gui = new dat.GUI({autoPlace:true}); 

Open in new window

Pradip ShenolkarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Try this instead of your current lines 14-16 in abc.js:
    gui.add(gui_controls,'option1').listen().onChange(function(value) { gui_controls.option1 = true; gui_controls.option2 = false; gui_controls.option3 = false; } );
    gui.add(gui_controls,'option2').listen().onChange(function(value) { gui_controls.option1 = false; gui_controls.option2 = true; gui_controls.option3 = false; } );
    gui.add(gui_controls,'option3').listen().onChange(function(value) { gui_controls.option1 = false; gui_controls.option2 = false; gui_controls.option3 = true; } );

Open in new window

Note that it's a bit quick & dirty. I found some code in the google documentation but found a problem with setting the value of the checkboxes, it seems they stay checked as far as the browser is concerned so clicking on them a second time did nothing, the third time was ok again... That's why I added the setting to true of the clicked box which shouldn't be necessary normally I would think.

[edit] live example here:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.