[whatwg] Scripting and WF2 repetition model?
dsr at w3.org
Wed Mar 14 11:53:49 PDT 2007
I am trying to put together a demo for Web Forms 2.0 where each row
has a product name, quantity and unit price, and there is a summary
field at the end of the form showing the total price.
I have been able to get the repetition to work fine, once I realized
that the thead and tbody elements are needed, without them the
column headers mysteriously appear at the bottom of the table, but
perhaps that's just a bug in Opera 9.
What I haven't yet worked out is how to address the fields in each
row from the onforminput event handler set on the form element.
In the following, I get an alert that the form object is missing the
row, and then an error. Any ideas on how to address the fields in
a script that iterates across the rows and fields?
var form = document.forms;
if (!form) alert("missing form");
if (!form.row) alert("form is missing row");
alert("rows = " + form.row.item.value);
<form name="form1" onsubmit="false" onforminput="update()">
<legend>Repeating groups of fields</legend>
<td>Price Per Unit</td>
<tr id="lineitem" repeat="template" repeat-start="4">
<td><input name="row[lineitem].item" type="text" title="product
<td><input name="row[lineitem]quantity" type="number" title="number
<td><input name="row[lineitem]unitprice" type="number" title="price
<p><label for="total">Total price</label>
<input name="total" readonly="readonly">
Dave Raggett <dsr at w3.org> http://www.w3.org/People/Raggett
More information about the whatwg