The trick here is to assign unique variables in the form for each comment. Something like this, where the comment ID is 1234…
<form...>
<!-- use a hidden field to pass the comment ID so you can write the data into your database -->
<input type="hidden" name= "helpful" value="1234">
<!-- assign your radio buttons using comment ID as the unique ID -->
<label for="yes1234"><input type="radio" id="yes1234" name="helpful" value="1"> Yes</label>
<label for="no1234"><input type="radio" id="no1234" name="helpful" value="2"> No</label>
</form>
Note: the for and id attributes are in valid if starting with a number so just prepend alpha characters
Not at all, in fact I can’t imagine many people wanting to sift through numerous comments to mark them useful. I’d think that the majority of times you’d only select one item to mark…?
Depends how you want it to work. You could wrap all comments in one form and let users select many items, but then where would you put your submit button(s)? Could make it hard work! I’d say one form per comment, keep it simple.
If you want each pair of radio buttons to be treated separately then you also need to insert the comment ID in the end of the name. If you do that then the hidden helpful field would not be needed,
<form...>
<!-- assign your radio buttons using comment ID as the unique ID and name -->
<label for="yes1234"><input type="radio" id="yes1234" name="helpful1234" value="Y"> Yes</label>
<label for="no1234"><input type="radio" id="no1234" name="helpful1234" value="N"> No</label>
<label for="yes2468"><input type="radio" id="yes2468" name="helpful2468" value="Y"> Yes</label>
<label for="no2468"><input type="radio" id="no2468" name="helpful2468" value="N"> No</label>
</form>
Let me explain again what I am trying to do, and maybe you can share your thoughts with me - since you generally give good advice!
Beneath one of my articles are Member Comments. I expect any given article could have from 50 to 500 Comments.
For each Member Comment, I want to ask at least 2 Questions:
1.) Was this Comment helpful? (Yes/No)
2.) How would you rate this Comment? (1 to 5 Stars)
My assumption is that a person would be reading through the Comments, see one that stands out - good or bad - and decide to take my “mini-survey” on said Comment.
As such, the design I was going for is one which assumes a reader is submitting answers for ONE COMMENT versus going through and rating every Comment.
The more I think about it, it sure seems to me that each Comment would be encapsulated in its own Form.
Is my thinking correct?
Is there any damage if I have 500 Comments on an Article, and thus I need 500 Forms??
Right now, all of an Article’s Comments are already wrapped in a Form because I use that when the reader wants to sort things or navigate between pages.
I do NOT think it is a good idea to let my two questions above exists in this current “parent” Form because then a reader could go crazy and start rating everything under the stars all at once.
If it IS okay to encapsulate my two Comment questions in a “mini” Form, then the next question would be, how do I do the HTML?
Would your advice above still apply or not?
It seems to me that I would want the NAME to be the same for everything, because there would be a distinct Form for each Comment, and so there wouldn’t be any “collisions”.
Anyways, I would be interested to hear your thoughts, Stephen - along with any other gurus lurking out there!
bluedreamer’s solution will work if you want each as a separate form . I was providing an alternative for if you want everything in the one form. It all depends on how many submit buttons you want on the page and what you want to happen if someone decides to fill out fields in more than one form before trying to submit any of it.
As long as it is clear to your visitors whether the page is all one form or lots of separate forms then there shouldn’t be too much of a problem. You will get people upset if they fill out all of the fields thinking it is all one form and then submitting only captures a small part of what they typed or of they think they are all separate forms, part fill out one then change their mind, go to fill out another and find that the part they thought they’d abandoned part way through gets submitted with the one they wanted to submit.