[−][src]Static p5_sys::global::createRadio
pub static createRadio: CreateRadioInternalType
Creates a radio button element in the DOM.It also helps existing radio buttons assign methods of p5.Element.
.option(value, [label])
can be used to create a new option for the element. If an option with a value already exists, it will be returned. Optionally, a label can be provided as second argument for the option..remove(value)
can be used to remove an option for the element..value()
method will return the currently selected value..selected()
method will return the currently selected input element..selected(value)
method will select the option and return it..disable(Boolean)
method will enable/disable the whole radio button element.
Examples
let radio; function setup() { radio = createRadio(); radio.option('black'); radio.option('white'); radio.option('gray'); radio.style('width', '60px'); textAlign(CENTER); fill(255, 0, 0); } function draw() { let val = radio.value(); background(val); text(val, width / 2, height / 2); }
let radio;
function setup() {
radio = createRadio();
radio.option('apple', 1);
radio.option('bread', 2);
radio.option('juice', 3);
radio.style('width', '60px');
textAlign(CENTER);
}
function draw() {
background(200);
let val = radio.value();
if (val) {
text('item cost is $' + val, width / 2, height / 2);
}
}
Overloads
containerElement
An container HTML Element either a div
or span inside which all existing radio inputs will be considered as options.
name?
A name parameter for each Input Element.
name
A name parameter for each Input Element.