Usage (signatures)
board.create('checkbox', [x, y, label]);
x and y are the coordinates of the lower left corner of the text box.
The position of the text is fixed if x and y. The position is variable if x or y are functions.
The label of the input element may be given as string or function.
The value of the checkbox can be controlled with the attribute checked
The HTML node can be accessed with element.rendNodeCheckbox
Parameters
| Name | Type | Description |
|---|---|---|
x |
NumberLike | |
y |
NumberLike | |
label |
String | function |
Examples
Create a checkbox element at position [0,3]
var checkbox = board.create('checkbox', [0, 3, 'Change Y'], {});
var p = board.create('point', [
function(){ return 0.5;}, // X-coordinate
function() {
y = 0.5;
if (checkbox.Value()) {
y += 0.5;
}
return y;
}]);
Change position of point when clicking on checkbox
var checkbox = board.create('checkbox', [0, 4, 'Click me']),
p = board.create('point', [1, 1]);
JXG.addEvent(checkbox.rendNodeCheckbox, 'change', function() {
if (this.Value()) {
p.moveTo([4, 1]);
} else {
p.moveTo([1, 1]);
}
}, checkbox);
Change texts when clicking on checkbox
var i1 = board.create('input', [1, 5, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
var c1 = board.create('checkbox', [1, 3, 'label 1'], {});
var b1 = board.create('button', [1, 1, 'Change texts', function () {
i1.setText('g(x)=');
i1.set('cos(x)');
c1.setText('label 2');
b1.setText('Texts are changed');
}],
{cssStyle: 'width:200px'});
Attributes
Own
checked
- Description
Control the attribute "checked" of the HTML checkbox.
- Type
- Boolean
- Default Value
- false
- Source
- options.js, line 4888
disabled
- Description
Control the attribute "disabled" of the HTML checkbox.
- Type
- Boolean
- Default Value
- false
- Source
- options.js, line 4876
Inherited
Members
Own
none
Inherited
Methods
Own
Value() → {String}
Returns the value of the checkbox element
Returns
value of the checkbox.
- Type
- String
Details
- Source
- element/checkbox.js, line 235
Inherited
Events
Own
none