I have a set of elements that can be in different states. I want to allow the user to use an (X) HTML form for
- change state and
- easily view the status of a group of objects
... so for this I need a layout:
| item1 | radio button for state 1 | radio for state 2 | ... | [update button] | | item2 | radio button for state 1 | radio for state 2 | ... | [update button] |
etc .. I prefer the switches to display lists so that the user can visually scan things in a certain state.
It seemed to me that this is absolutely tabular data. The only problem: you cannot have forms inside the table that intersect the cells of the table (i.e. <tr> <form> <td> ... not valid).
I thought: βHey, I could have one giant form wrapping the table, and so that the [update button] value contains the identifiers for each row!β It turns out that some versions of IE send ALL BUTTONS RECORDING BUTTONS in any form.
So I thought it might be possible to fold it with a <div> and put the forms inside a single <td> . But then they break the line into each <div> . So I set their width and made them float: left . But then they are wrapped inside the table cells if the table row is wider than the page and the radio controls do not match the headers.
Can this be laid out, as I suppose? XHTML below shows the intended structure. Note what happens if you resize the browser window under the width of the table (ideally, the name will break or a scroll bar will appear in the table).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>Test</title> <style type="text/css"> .state-select, .thing-state-name, .update { float: left; width: 8em; } .state-select { text-align: center; } </style> </head> <body> <table> <thead> <tr> <th class="thing-name-header">Thing</th> <th> <div class="thing-state-name">Present</div> <div class="thing-state-name">Absent</div> <div class="thing-state-name">Haven't looked</div> </th> </tr> </thead> <tbody> <tr> <td>Apple</td> <td> <form action="something" method="post"> <input type="hidden" name="id" value="1" /> <div class="state-select"><input type="radio" name="presence" value="present" checked="checked" /></div> <div class="state-select"><input type="radio" name="presence" value="absent" /></div> <div class="state-select"><input type="radio" name="presence" value="unknown" /></div> <div class="update"><input type="submit" value="Update" /></div> </form> </td></tr> <tr> <td>Orange</td> <td> <form action="something" method="post"> <input type="hidden" name="id" value="2" /> <div class="state-select"><input type="radio" name="presence" value="present" /></div> <div class="state-select"><input type="radio" name="presence" value="absent" checked="checked" /></div> <div class="state-select"><input type="radio" name="presence" value="unknown" /></div> <div class="update"><input type="submit" value="Update" /></div> </form> </td></tr> <tr> <td>David Bowie</td> <td> <form action="something" method="post"> <input type="hidden" name="id" value="3" /> <div class="state-select"><input type="radio" name="presence" value="present" /></div> <div class="state-select"><input type="radio" name="presence" value="absent" /></div> <div class="state-select"><input type="radio" name="presence" value="unknown" checked="checked" /></div> <div class="update"><input type="submit" value="Update" /></div> </form> </td></tr> </tbody> </table> </body> </html>
source share