Pradip Shenolkar
asked on
Uncheck the checked checkbox when clicked in javascript
The problem: When I click on checked checkbox they should get unchecked.
jsp page:
abc.js
Please download dat.gui.min.js from attachment.
dat.gui.min.js
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>
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; } );
}
Please download dat.gui.min.js from attachment.
dat.gui.min.js
Very hard to tell what you are trying to do but can't you do it with jquery or just plain javascript?
ASKER
No I can't use plain javascript or jquery.
I need to use dat.gui library
I need to use dat.gui library
Ok, sorry I can't help you then.
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.
So instead of using checkbox control, can you use radio control ??
In that case, you do not need have any javascript.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Robert Schutt
Thanks alot.
It works as I wanted.
Thanks alot.
It works as I wanted.