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


Groups > comp.lang.javascript > #15462

Re: radio buttons with. checkbox

From emf <emfril@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: radio buttons with. checkbox
Date 2012-08-20 08:29 -0400
Organization Aioe.org NNTP Server
Message-ID <k0tacn$l8s$1@speranza.aioe.org> (permalink)
References <k0o75t$iac$1@speranza.aioe.org> <2760364.jIkiNM8doB@PointedEars.de>

Show all headers | View raw


On 2012-08-18 13:18 Thomas 'PointedEars' Lahn wrote:
> emf wrote:
> ^^^
> Who?

Check the sig in this message.

>> In my Spherical Triangle Calculator:
>>
>> https://files.nyu.edu/emf202/public/js/spherical.html
>>
>> one can select 1 of 3 radio buttons. Degrees and Radians affect the
>> input and the output, while degmin affects the output only.
>>
>> I considered making the deg°min' a checkbox instead:
>>
>> https://files.nyu.edu/emf202/public/js/spherical2.html
>>
>> but there are problems with the code. To begin with, if you click
>> Radians, the degmin checkbox *is* disabled, but then when I click Clear
>> while the Degrees is selected the degmin remains disabled.
>
> You could call the "Degrees" radiobutton's onclick() property when the
> "Clear" button is activated, or you could simply call the function called
> the former's click event listener.  The latter is probably more compatible,
> but in more than a decade of browser scripting I have not yet encountered a
> DOM where calling the onclick() property would fail under these
> circumstances.¹  You may even call the radiobutton's click() method instead
> if it has any, or despatch a `click' event to it, but tests as to that are
> pending as well.
>
> ¹  Indeed, the HTML5 Working Draft suggests that calling the onclick()
> property is well-supported even with a HTML 4.01 DOM API:
> <http://www.w3.org/TR/html5/webappapis.html#event-handlers-on-elements-
> document-objects-and-window-objects>
>
>> Also, I'd prefer if the radio buttons and the checkbox are outside the
>> dataForm, so their settings won't change with Clear, but then when
>> clicking Calculate, it should be able to tell the current status of the
>> buttons/checkbox.
>
> A reset button in a form is usually a bad idea to begin with as it carries
> with it the risk of accidentally undoing all user inputs², but in your case
> an exception can be made.  Therefore, it is a bad idea to place form
> controls outside the form because then it could not be made to work without
> client-side DOM scripting, which you should consider implementing.

> ²  <http://www.useit.com/alertbox/20000416.html>

I believe I've solved the problems, though I am not sure that there are 
other more elegant solutions:

https://files.nyu.edu/emf202/public/js/spherical2.html

Instead of disabling the checkbox, I have it disappear. I had to reset 
the form onload, because when reloading the webpage, something that I 
had to do often when working on the code, the checks would not change 
from what they were before, while the using would change. And instead of 
<input type="reset"...> I now use

<input type="button" ... onclick="clearValues()>

pointing to a function that resets only the text fields one by one, but 
not the buttons and the checkbox. So now the radio buttons and the 
checkbox now are all inside the form. It is true that the reset is a 
kind of a blunt instrument; thanks for the link.

>> […]
>>                   <label for="rads" style="padding-right:1em;">
>>                       <input type="radio" name="formats"
>>                         onClick="inputOutput(0)";> Radians
>>                   </label>
>>                    <label for="degr" style="padding-right:1em;">
>>                        <input type="radio" name="formats"
>>                          onClick="inputOutput(1)"; checked> Degrees
>>                   </label>
>>                  <label for="dgmn2" style="padding-right:1em;">
>>                       <input type="checkbox" name="dgmn"
>>                         onClick="inputOutput(2)"> deg°min'
>>                   </label>
>> ...
>
> Your LABEL elements do not work (clicking them does not focus the control)
> in Chromium 21.0.1180.75 Built on Debian wheezy/sid, running on Debian 6.0.5
> (150248), and most certainly other browsers, because you have not specified
> the `rads' aso. IDs on the corresponding form controls.  With this approach,
> you need to omit the `for' attribute on the LABEL elements.

I tend to be "minimalist" removing from the code what does not seem 
clearly necessary, so at one point, since id is not an essential 
attribute of label, I decided to remove them... Later I observed that 
the labels were not working as they should, but because of other 
problems I had left the issue aside. Now they are back.

> However, indication of control activation might be rendered better (such as
> a dotted line around the text of the label of the activated control,
> excluding leading and trailing whitespace, as users would expect from other
> GUIs) if you used the `for' attribute and specified a corresponding `id'
> attribute on the corresponding control, but would not have the control as a
> child element of the LABEL element.
>
> <http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL>
>
>
> PointedEars

Thanks for your input, and I would appreciate any further comments.

emf

PS. How do you insert number superscripts when typing a message? I am 
using DejaVu fonts that has in superscript form all the numbers, but I 
do not see an easier way to insert them than by opening the Character Map.

-- 
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

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


Thread

radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-18 10:03 -0400
  Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-18 17:36 +0200
    Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-19 09:30 -0400
      Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-19 12:11 -0400
        Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-20 14:00 +0200
          Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-20 09:05 -0400
            Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-20 16:11 +0200
              Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-21 05:25 -0400
                Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-21 14:36 +0200
                Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-22 12:24 +0200
      Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-20 12:13 +0200
      Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-20 16:27 +0200
        Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-20 21:58 +0200
        Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-21 10:58 -0400
          Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-22 10:41 +0200
          Re: radio buttons with. checkbox "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-22 10:14 +0000
          Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-22 14:31 +0200
  Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-18 19:18 +0200
    Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-20 08:29 -0400
      Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-20 16:25 +0200
        Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-21 06:06 -0400
          Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-21 14:33 +0200
            Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-21 10:51 -0400
              Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-22 11:42 +0200
              Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-22 14:27 +0200
            Re: radio buttons with. checkbox Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-22 20:24 +0100
              Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-23 11:06 +0200
                Re: radio buttons with. checkbox Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-25 17:01 +0100
          Re: radio buttons with. checkbox Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-22 19:58 +0100
        Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-22 02:20 -0400
          Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-22 10:44 +0200
          Re: radio buttons with. checkbox SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-22 14:40 +0200
            Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-08-26 00:16 -0400
            Re: radio buttons with. checkbox emf <emfril@gmail.com> - 2012-09-03 07:19 -0400
    Re: radio buttons with. checkbox David Mark <dmark.cinsoft@gmail.com> - 2012-09-03 21:02 -0700
      Re: radio buttons with. checkbox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-04 13:44 +0200
        Re: radio buttons with. checkbox David Mark <dmark.cinsoft@gmail.com> - 2012-09-04 06:00 -0700

csiph-web