disable a checkbox

101 views
Skip to first unread message

Bernat Martinez

unread,
May 6, 2015, 11:47:35 AM5/6/15
to jsxg...@googlegroups.com
Hello,

I have created a checkbox
var c11 = brd12.create('checkbox', [9.5, 16.5, ' '], {id:'a11'});

The I want a button to disable it , after students answering the question
I have used
document.getElementById('a11').disabled= true

and
document.getElementById('a11').setAttribute('disabled', 'true');

any hint?

Thanks in advance

pablo...@gmail.com

unread,
May 6, 2015, 12:19:50 PM5/6/15
to jsxg...@googlegroups.com
Alfred, will it be useful to add a 'disable' method to the checkbox element and a 'change' event?

https://groups.google.com/forum/#!topic/jsxgraph/Z9Dm9PDBwiY

Alfred Wassermann

unread,
May 7, 2015, 4:56:39 AM5/7/15
to jsxg...@googlegroups.com, pablo...@gmail.com, pablo...@gmail.com
Dear Pablo,
very good suggestion! I immediately implemented support for the attribute "disabled" for the elements button, checkbox and input.
It will be available in today's nightly build.

It can be used like this:

var check = board.create('checkbox', [0, 4, 'Click me'], {disabled: true});
check
.setAttribute({disabled:false});

If one needs access to the HTML node of the checkbox node, it can be accessed directly via:

check.rendNodeCheckbox

The access with getElementById is a little bit more complex. The id of the checkbox is "idOfDiv_idOfText_checkbox". For buttons it is "idOfDiv_idOfText_button" and for input it is "idOfDiv_idOfText_input". In the above example by Bernat and assuming that the div hosting the construction has the id "box" the  checkbox can be accessed with

document.getElementById('box_a11_checkbox')

Your second suggestion, adding a changeevent, is a little bit more involved. We have to think about it. A good solution would be to allow all possible HTML events. But the question is if it is more simple to just use the HTML node check.rendNodeCheckbox than piping events through JSXGraph.
Please give us comments about this issue.

Best wishes,
Alfred

pablo...@gmail.com

unread,
May 7, 2015, 5:02:24 AM5/7/15
to jsxg...@googlegroups.com, pablo...@gmail.com
I was suggesting adding the 'change' event just because I saw a question the other day.
I don't have a specific use case in mind.
The only downside of accessing the HTML element is that you can't use it with JessieCode in a safe way.

Thank you for the super fast implementation.

Alfred Wassermann

unread,
May 7, 2015, 5:22:54 AM5/7/15
to jsxg...@googlegroups.com, pablo...@gmail.com, pablo...@gmail.com
That's right. We will try to find a suitable solution which works also for JessieCode.

Darko Drakulic

unread,
May 7, 2015, 7:16:54 PM5/7/15
to jsxg...@googlegroups.com, pablo...@gmail.com
Hi,

Is it possible to use CSS styles for button, checkbox and input elements. I need a width and height attributes for button (but border, colors and others are useful as well).

I also discovered that 
brd.create("text", [0,0,"<input .../>"]) 
does not work with the last version.

All the best,
Darko
Reply all
Reply to author
Forward
0 new messages