Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #41391

Re: four-state checkbox?

From The Natural Philosopher <tnp@invalid.invalid>
Newsgroups comp.lang.javascript
Subject Re: four-state checkbox?
Date 2023-08-05 18:31 +0100
Organization A little, after lunch
Message-ID <uam12e$1qlch$5@dont-email.me> (permalink)
References <37b72956-7171-4f6a-baf5-0bcdb2e151b5n@googlegroups.com> <kj6t23F83ojU1@mid.individual.net>

Show all headers | View raw


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
> 
> 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
>> { "&nbsp;", "&#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.
> 
It's not hard to do in Javascript, simply have an onmousedown() event 
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.




-- 
In theory, there is no difference between theory and practice.
In practice, there is.
-- Yogi Berra

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

four-state checkbox? luserdroog <luser.droog@gmail.com> - 2023-08-03 08:04 -0700
  Re: four-state checkbox? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2023-08-03 14:46 -0700
  Re: four-state checkbox? Arno Welzel <usenet@arnowelzel.de> - 2023-08-05 14:19 +0200
    Re: four-state checkbox? The Natural Philosopher <tnp@invalid.invalid> - 2023-08-05 18:31 +0100
      Re: four-state checkbox? Arno Welzel <usenet@arnowelzel.de> - 2023-08-06 13:47 +0200
  Re: four-state checkbox? luserdroog <luser.droog@gmail.com> - 2023-08-05 05:55 -0700
    Re: four-state checkbox? Arno Welzel <usenet@arnowelzel.de> - 2023-08-06 13:50 +0200
    Re: four-state checkbox? JJ <jj4public@outlook.com> - 2023-08-07 12:04 +0700
      Re: four-state checkbox? luserdroog <luser.droog@gmail.com> - 2023-08-07 07:56 -0700

csiph-web