Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15476
| From | emf <emfril@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: radio buttons with. checkbox |
| Date | 2012-08-21 05:25 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <k0vk0p$pj0$1@speranza.aioe.org> (permalink) |
| References | (2 earlier) <k0qpjr$6s8$1@speranza.aioe.org> <k0r30j$t06$1@speranza.aioe.org> <503226e3$0$6218$ba4acef3@reader.news.orange.fr> <k0tcfo$q8t$1@speranza.aioe.org> <5032459b$0$6216$ba4acef3@reader.news.orange.fr> |
On 2012-08-20 10:11 SAM wrote:
> Le 20/08/12 15:05, emf a écrit :
>>
>> if (using !== undefined) {
>
> if(typeof using != 'undefined') {
Now the file I am editing is
https://files.nyu.edu/emf202/public/js/spherical.html
rather than spherical2.html
I inserted javascript code calling the imputOutput() function in the
body immediately after the checkbox, so my problem with the null
elements was solved.
>
> Your code :
> if (rads.checked === true) {
> can simply be :
> if (rads.checked) {
>
>
> The spanCheckbox will be hidden if the radians is checked :
> spanCheckbox.style.visibility = rads.checked? "hidden" : "";
Yes and yes. You take from me the pleasure of improving the code myself
at some future point. By writing (rads.checked === true) I somehow
wanted to make absolutely sure I wouldn't get some error message, though
I knew I shouldn't have a used the shorter version.
>
> function inputOutput() {
> var rads = document.getElementById("rads"),
> degr = document.getElementById("degr"),
> dgmn = document.getElementById("dgmn"),
> spanCheckbox = document.getElementById("degmin");
I'll start adopting this kind of syntax.
> spanCheckbox.style.visibility = rads.checked? "hidden" : "";
> using = (typeof using == 'undefined')? ".###°" :
> rads.checked? 'r' :
> !dgmn.checked? ".###°" : "#°##.#'";
> }
I was convinced by Thomas arguments and reverted to making the checkbox
disabled rather than having it disappear.
Now I do not need an if statement to see if using is undefined.
I do not feel comfortable of using the shorthand syntax above (using =
...) when it gets more complicated.
> function clearValues() { // it resets only the text fields
> var f = document.dataForm.elements,
> n = f.length;
> while(n--) if(f[n].type == 'text') f[n].value = '';
> }
Nice! I have to apply this to some other code I have written. Except
that, again, I feel more comfortable with a simpler for loop. I do not
find this while(n--) intuitive enough for me.
Thanks,
emf
--
Date Calculator with all-purpose JS code
https://files.nyu.edu/emf202/public/js/dateCalculator.html
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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