I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
luserdroog, 2023-08-03 17:04:
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
A *checkbox* is there to show a *checked* or *unchecked* state.
If you need 4 different states, then it is not a checkbox but just some element which shows 4 states. And in most cases a radio group is much
better for this - then users can clearly see what options are available
and can choose one of the options.
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
No. You need to implement it on your own or check if Angular, React, Vue
or Bootstrap have a component for that.
On 05/08/2023 13:19, Arno Welzel wrote:[...]
luserdroog, 2023-08-03 17:04:
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
It's not hard to do in Javascript, simply have an onmousedown() eventIs there an existing element that's closer, like an <option> I guess?
No. You need to implement it on your own or check if Angular, React, Vue
or Bootstrap have a component for that.
that rotates an internal variable round 4 states and updates an onscreen
area with text, or selects e.g. a pseudo LED to light up to indicate the state of the control.
I have long since given up using any HTML input controls. They look like
shit and they are hard to get looking nice across browser variations.
CSS styles the whole thing and javascript handles all user input. And
ajax calls update the server.
On Thursday, August 3, 2023 at 10:04:58 AM UTC-5, luserdroog wrote:
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
Thanks Michael and Arno. Here's my idea for the interface a little more fleshed out:
<click-box cycle
states="empty checkmark xmark questionmark"
empty=""
checkmark="&x#..."
xmark="&x#..."
questionmark="?"></click-box>
On Thursday, August 3, 2023 at 10:04:58 AM UTC-5, luserdroog wrote:
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make
a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
Thanks Michael and Arno. Here's my idea for the interface a little more fleshed out:
<click-box cycle
states="empty checkmark xmark questionmark"
empty=""
checkmark="&x#..."
xmark="&x#..."
questionmark="?"></click-box>
Specifying the "cycle" attribute selects the (currently only) behavior
of cycling through states. The .value attribute/property of the
component will be reported as one of the strings from the "states"
attribute. If a state value itself is defined as an attribute then the
value of that attribute will be used as the label for visual display, otherwise the value string will be used as the label.
This seems like it covers what I need, allowing extension without too
much YAGNI, and I can stick one in a <template> and then clone that
around where I need it, I think. Maybe it should also offer a .textContent output.
On Sat, 5 Aug 2023 05:55:08 -0700 (PDT), luserdroog wrote:
On Thursday, August 3, 2023 at 10:04:58 AM UTC-5, luserdroog wrote:
I want to make a control that looks like a checkbox but cycles through
4 states: { blank, checkmark, X-mark, questionmark }. What's the best
way to build such a thing. I'm thinking it wouldn't be too hard to make >> a web component that just controls a span and flips through
{ " ", "&#x...whatevers", ... "?" } strings.
Is there an existing element that's closer, like an <option> I guess?
Thanks Michael and Arno. Here's my idea for the interface a little more fleshed out:
<click-box cycle
states="empty checkmark xmark questionmark"
empty=""
checkmark="&x#..."
xmark="&x#..."
questionmark="?"></click-box>
Specifying the "cycle" attribute selects the (currently only) behavior
of cycling through states. The .value attribute/property of the
component will be reported as one of the strings from the "states" attribute. If a state value itself is defined as an attribute then the value of that attribute will be used as the label for visual display, otherwise the value string will be used as the label.
This seems like it covers what I need, allowing extension without tooThat would be a custom input interface element. e.g.
much YAGNI, and I can stick one in a <template> and then clone that
around where I need it, I think. Maybe it should also offer a .textContent output.
https://jsbin.com/dixapihuto/1/edit?html,css,js,output
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 251 |
Nodes: | 16 (2 / 14) |
Uptime: | 05:24:22 |
Calls: | 5,541 |
Calls today: | 7 |
Files: | 11,675 |
Messages: | 5,106,244 |
Posted today: | 1 |