From: Ry Nohryb on
On Aug 2, 10:49 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> But that's not an attribute (it's a DOM property).  Why does it seem
> the whole world is confused about this?

I said "All *html*elements'*attributes* are always strings, ISTM.
--
Jorge.
From: Ry Nohryb on
On Aug 2, 10:49 am, David Mark <dmark.cins...(a)gmail.com> wrote:
> (...)
> The only (direct) way to get an attribute value is with the
> getAttribute method. (...)

That's not true. Many/most/all? -standard- attributes are (directly)
reflected in JSLand as properties, e.g. document.body.style.marginTop
or document.body.bgColor. It might not be so in the most borken
browser ever... (?)
--
Jorge.
From: David Mark on
On Aug 2, 11:34 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
> On Aug 2, 10:49 am, David Mark <dmark.cins...(a)gmail.com> wrote:
>
>
>
> > But that's not an attribute (it's a DOM property).  Why does it seem
> > the whole world is confused about this?
>
> I said "All *html*elements'*attributes* are always strings, ISTM.

Go back and read the part you snipped and you will see why I corrected
your mistake. It doesn't matter if you knew what you were saying.
The context in which you said it was wrong, making it look like there
was confusion about the issue of the checked property of a checkbox.

And attributes aren't anything. They are an abstract concept. You
can retrieve attribute values as I indicated and, if present, they
will be returned in string form (in most browsers).
From: RobG on
On Aug 2, 6:31 am, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
wrote:
> In comp.lang.javascript message <4c53597c$0$285$14726...(a)news.sunsite.dk>, Fri, 30 Jul 2010 23:00:02, FAQ server <javascr...(a)dotinternet.be>
>
> posted:
>
> >FAQ Topic - Why does 1+1 equal 11? or How do I convert a
> >string to a number?
> >Form control values are strings,
>
> That is true even for checkboxes, it seems.
>
> In my IE & FF & Opera, checkbox.value is the string 'on'.
>
> In my Safari and Chrome, it is 'on' if checked, else ''.

It should return whatever string value you have assigned to the
element's value attribute. The value attribute is required in HTML
4.01 for radio buttons and checkboxes.

<URL: http://www.w3.org/TR/html401/interact/forms.html#adef-value-INPUT
>

I'll take a punt and say you didn't assign a value and are getting
whatever the browser decides to assign to invalid markup. Play with
the following:

<div>
<input type="radio" name="rad0" onclick="
alert(
'value property: ' + this.value +
'\nvalue attribute: ' + this.getAttribute('value') +
'\ntypeof checked property: ' +
(typeof this.checked) + ' ' + this.checked +
'\ntypeof checked attribute: ' +
(typeof this.getAttribute('checked')) + ' ' +
this.getAttribute('checked')
);
">
</div>

HTML 5 is vague about it:

"Form controls have a value and a checkedness. (The latter is only
used by input elements.) These are used to describe how the user
interacts with the control."

<URL: http://www.w3.org/TR/html5/association-of-controls-and-forms.html#concept-fe-value
>

The word "checkedness" is awkward and confusing, what's wrong with
"checkedstate"? I don't think value has anything to do with how a user
interacts with a control.


> In all, I expect checkbox.checked is a boolean.

The checked property is specified in DOM 2 HTML as being boolean. Any
other type is non-conforming.

<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-30233917 >


--
Rob
From: Ry Nohryb on
On Aug 3, 3:32 am, RobG <rg...(a)iinet.net.au> wrote:
> On Aug 2, 6:31 am, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
> wrote:
> (...)
>
> > In all, I expect checkbox.checked is a boolean.
>
> The checked property is specified in DOM 2 HTML as being boolean. Any
> other type is non-conforming. (...)

The type of the checked *attribute* is boolean, but its value as
reflected in JSLand is *not* of boolean type.
--
Jorge.