Link to home
Start Free TrialLog in
Avatar of Pradip Shenolkar
Pradip ShenolkarFlag for India

asked on

Uncheck the checked checkbox when clicked in javascript

The problem: When I click on checked checkbox they should get unchecked.


jsp page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<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>
</head>

<body onload="gui();">

</body>
</html>

Open in new window


abc.js
var gui_control = function () {

    this.option1=false;
    this.option2=false;
    this.option3=false;    
}

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


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


Please download dat.gui.min.js from attachment.
dat.gui.min.js
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Very hard to tell what you are trying to do but can't you do it with jquery or just plain javascript?
Avatar of Pradip Shenolkar

ASKER

No I can't use plain javascript or jquery.
I need to use dat.gui library
Ok, sorry I can't help you then.
Avatar of Pravin Asar
From the description of the problem, looks like you want only one value selected.
So instead of using checkbox control, can  you use radio control ??
In that case, you do not need have any javascript.
ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Robert Schutt
 Thanks alot.
 It works as I wanted.