[HTML5] [whatwg] Scripting and WF2 repetition model?

Ian Hickson ian at hixie.ch
Thu Mar 15 07:53:04 PDT 2007


On Thu, 15 Mar 2007, Dave Raggett wrote:
> 
> Thanks for the helpful reply. Unfortunately, Opera 9 (Linux) reports a 
> type error on calling getElementsByName("row1.quantity").

Oh, try invoking that on the document instead of the element, that should 
do it. My bad.


> By using alert and innerHTML, I see that row1 has the following content:
> 
> <TD><INPUT name="row1.item" type="text" title="product name"></TD>
> <TD><INPUT name="row1.quantity" type="number" title="number purchased"></TD>
> <TD><INPUT name="row1.unitprice" type="number" title="price per unit"></TD>
> 
> A work around would be to use getElementsByTagName on the input elements 
> for the row, as the position of the fields of interest within the row is 
> known in advance. That works when it comes to getting the requisite 
> fields for quantity and unitprice, but mysteriously their value property 
> is always blank despite evidence to the contrary on the browser 
> rendering of the page.

Sounds like a bug in Opera.


> I have to admit to a certain amount of puzzlement over the WF2 choice of 
> name syntax for repeating fields. It would have been a lot simpler to 
> avoid the period, so that the name was consistent with ECMAScript, HTML4 
> and DOM1.

There is no name syntax for repeating fields in WF2. You can use whatever 
syntax you like. All that's going on is that the template name is being 
prefilled. For example, you could do:

   <input name="row-number-[row]" value="this is the row number #[row]">

...and it'll still do the substitution.

I agree that better JS shortcuts could make life easier. It's not clear 
how to provide those while still providing real DOM support. (XForms, 
e.g., gets around this by not providing real DOM support.)


> It also seems that DOM1 only defines getElementsByName on the document 
> object and not on every element. So it is not a big suprise when it 
> didn't work in Opera on the tr (row) element.

Indeed. Change it to the document and my script should work, in theory, 
notwithstanding any bugs.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the Help mailing list