W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2004

[whatwg] Repetition Template Rendering Fix for Script-enabled Clients

From: Matthew Raymond <mattraymond@earthlink.net>
Date: Mon, 28 Jun 2004 07:54:59 -0400
Message-ID: <40E00713.5020903@earthlink.net>
    I have yet to come up with a good way to keep the repetition 
template from rendering on script-enabled browsers. Here's a modified 
version of one of the examples from the Web Forms 2.0 draft:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
  <head>
   <title>Sample Order Form</title>
  </head>
  <body>
   <table>
    <tr>
     <th>Product</th>
     <th>Quantity</th>
    </tr>
    <script language="JavaScript" src="order_template.js"></script>
    <noscript>
     <tr id="order" repeat="template" repeat-start="3">
      <td><input type="text" name="row[order].product"></td>
      <td><input type="text" name="row[order].quantity" value="1"></td>
     </tr>
    </noscript>
   </table>
   <p><button type="add" template="order">Add Row</button></p>
   <p><button type="submit">Submit</button></p>
  </body>
</html>


    The file "order_template.js" would contain the following:

if(document.implementation && document.implementation.hasFeature &&
    document.implementation.hasFeature('WebForms', '2.0')) {
   document.write('<tr id="order" repeat="template" repeat-start="3">');
   document.write('<td>');
   document.write('<input type="text" name="row[order].product">');
   document.write('</td>');
   document.write('<td>');
   document.write('<input type="text" name="row[order].quantity" 
value="1">');
   document.write('</td>');
   document.write('</tr>');
}


    This would not change how the WF2 repetition model works with UAs 
that have disabled or non-existent scripting support, but it would 
prevent unwanted template blocks from showing up on script-enabled 
clients. I'll continue to work on a way to get the same effect without 
scripting.
Received on Monday, 28 June 2004 04:54:59 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:18 UTC