views:

54

answers:

2

Hi folks

Been using this site for ages and have never had to go as far as to ask my own question... cheers in advance.

I have a group of "questions" which are to be listed. The user then has to rank these questions as 1st, 2nd, and 3rd (there can be many more than three questions however).

The problem I have is that, if I make the radio button mutually exclusive in one direction - the user could rank all questions as #2, however if I make them mutually exclusive in the other direction, a user could rank the same question as #1, #2, AND #3.

Is there a way (maybe using jquery/Jscript) to make the radio buttons mutually exclusive in both directions?

EXAMPLE:

<table>
<tr>
    <th>Question</th><th>Rank #1</th><th>Rank #2</th><th>Rank #3</th>
</tr><tr>
    <td>QUESTION 1</td>
    <td><input type="radio" name="rank1" value="1" id="1_1" /></td>
    <td><input type="radio" name="rank2" value="1" id="1_2" /></td>
    <td><input type="radio" name="rank3" value="1" id="1_3" /></td>
</tr><tr>
    <td>QUESTION 2</td>
    <td><input type="radio" name="rank1" value="3" id="3_1" /></td>
    <td><input type="radio" name="rank2" value="3" id="3_2" /></td>
    <td><input type="radio" name="rank3" value="3" id="3_3" /></td>
</tr>

In the above example, the value is the question's ID (from the DB)

+4  A: 

Creative solution:

Why don't you use a widget? you could put questions like layers you can drag and move, example:

http://jqueryui.com/demos/sortable/

http://jqueryui.com/demos/draggable/#sortable

The first to appear would be the first one.

netadictos
I hadn't thought about that. The only problem is that one of the remits for the site was to keep these kinds of user interactions to a minimum as the users are probably going to be quite elderly (not a sweeping generalisation, but the site is geared towards the kind of elderly users who aren't computer savvy).
hubare
^^^ cheers for that, mind... Now that you've said it, it's probably a good idea to rethink the presentation of the data. Maybe use buttons which trigger post-backs and reorder the questions (or similar). Thanks
hubare
+1 for drag and drop. Senior Citizens should not have too much trouble picking it up, if you do it right, and if you show it, via animated gif as a tutorial or something.
Moin Zaman
Not sure about that. The part of the site I'm working on is geared towards people in sheltered accommodation and nursing homes. Whilst I'm not saying all people in this category wont respond well to this kind of interaction - a significant proportion would be put off by it.
hubare
do some user testing
Moin Zaman
A: 

You would have to use jQuery to get this effect working as I can't see a way of it working out of the box with HTML. Here is an example the gives the desired effect:

$(document).ready(function() {
    $(':radio').click(function() {
        $(this).parent().siblings().children(':radio').attr('checked', false);
    });
});
Andy Rose
Thanks. I think when it all goes into production, the UI will probably have to be looked at more closely, but this is exactly what I was looking for. Plus... that site's been bookmarked :)
hubare
I'm seeing jsfiddle being used more and more, almost as handy as SO itself
Andy Rose