From: Jim Menard Date: 2002-08-14T04:50:44+09:00 Subject: Re: Building tables dynamically with CGI class junderdown@msn.com (Jason Underdown) writes: > I am fully aware of CGI#th. Maybe I didn't explain myself well > enough. What I want to be able to do is something like the following > code (which doesn't work): > > cgi.table('border'=>'1') { > cgi.tr { cgi.th{"ID"} + cgi.th{"First"} + cgi.th{"Last"} } + > rows.collect { |row| > cgi.tr { > row.collect { |item| > cgi.td { item } > } > } > } > } > > My previous code posting works, but notice that since the header row > gets generated by the same loop which creates the table body, the > CGI#td method is used to generate the header cells instead of CGI#th. Change > row.collect { |item| > cgi.td { item } > } to > row.collect { |item| > cgi.td { item } > }.join("\n") because the value of the block needs to be a single string. Jim -- Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "Power corrupts. Absolute power is kinda neat." -- Jeffrey Kaplan in r.h.o.d