Looking for a method to create a matrix of radio buttons.
Easy enough, but here's the trick:
buttons must be mutually exclusive in both rows and columns.
Let's say they're in a 5x5 table (hence, the matrix)
If the user selects the button at row 2, column 1
all other buttons in row 2 and column 1 must be unchecked
I can do either a row or a column, but have not been able to do both.
Most of my work will be with PHP and HTML.
Any suggestions?
Thank you,
---Enki
Last edited by Enki; 07-06-2006 at 09:25 PM.
Reason: Changing the title/subject line
So if item 4,1 is checked then the rest of both row 4 and column 1 must be cleared? Use a square of (cleverly named) checkboxes rather than radio buttons and drive them with Javascript onclick handlers. The onclick handler can either manipulate the inputs directly or it can just submit the form and you can do it on the server in PHP.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan
for matrixes, its often simpler to use multidimensional arrays. Like say the first radio is num[0][0], the second will be num[0][1] all the way to the last one num[5][5]. so you only need to create two loops, one to uncheck all with the same x-element, and one to uncheck all with the same y-element
Bookmarks