Wednesday, September 10, 2014

HTML5: output tag

From w3school.com:
Attributes
= New in HTML5.
AttributeValueDescription
forelement_idSpecifies the relationship between the result of the calculation, and the elements used in the calculation
formform_idSpecifies one or more forms the output element belongs to
namenameSpecifies a name for the output element

Sample Code ( number HTML5 input type and  range HTML5 input type ):
<form oninput="amount.value = (hours.valueAsNumber * rate.valueAsNumber) + ((hours.valueAsNumber * rate.valueAsNumber) * vat.valueAsNumber)" onsubmit="return false">
<legend>Invoice</legend>
<label for="hours">Number of hours:</label>
 <input id="hours" min="0" name="hours" type="range" value="5" />100
<label for="rate">Rate:</label>
 <input id="rate" min="0" name="rate" type="number" value="1" />($'s)
<label for="vat">VAT:</label>
 <input id="vat" min="0" name="vat" type="number" value="0.20" />
Total: <strong>$<output for="hours rate vat" name="amount"></output>
</form>
Invoice
100
($'s)

Total: $

No comments:

Post a Comment