This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 9403 - The output element example is confusing
Summary: The output element example is confusing
Status: CLOSED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: pre-LC1 HTML5 spec (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://dev.w3.org/html5/spec/forms.ht...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-04 12:29 UTC by Mounir Lamouri
Modified: 2010-10-04 14:55 UTC (History)
5 users (show)

See Also:


Attachments

Description Mounir Lamouri 2010-04-04 12:29:18 UTC
In the specifications, the example for the output element is:
<form onsubmit="return false">
 <input name=a type=number step=any> +
 <input name=b type=number step=any> =
 <output onforminput="value = a.value + b.value"></output>
</form>

However, "a.value + b.value" is a string concatenation so if a.value='1' and b.value='2' we are getting "12" in output. It sounds the example idea is to show "3" instead of "12".

There are two solutions:
 1. using * instead of + so there will be no more confusion with + method of the string concatenation.
 2. changing onforminput to "value = parseFloat(a.value) + parseFloat(b.value);"
Comment 1 Ms2ger 2010-04-04 18:36:58 UTC
Or even better, make it
 <output onforminput="value = a.valueAsNumber + b.valueAsNumber"></output>
Comment 2 Mounir Lamouri 2010-04-04 21:29:43 UTC
Indeed, .valueAsNumber is even better ;)
Comment 3 Ian 'Hixie' Hickson 2010-04-12 23:39:05 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter's comments.
Comment 4 contributor 2010-04-12 23:40:30 UTC
Checked in as WHATWG revision r5005.
Check-in comment: Make the example make more sense.
http://html5.org/tools/web-apps-tracker?from=5004&to=5005