doubledee — 2014-07-05T11:48:43-04:00 — #1
Not sure where to ask this question...
On my website, I allow Members to post Comments beneath Articles.
And for each Comment, I want to add a radio-button pair so people can vote on "Was this Comment helpful? __Yes __No"
The problem is that it appears all of my Yes/No button pairs are being treated as one gigantic group?! :eek:
What I want is each pair to be discrete and linked to the "Submit" button next to it.
In other words, I do NOT want people to go through voting for every Comment all at the same time. This is a "one-off vote" if that makes sense?
How can I achieve the design I want?
bluedreamer — 2014-07-05T13:02:35-04:00 — #2
The trick here is to assign unique variables in the form for each comment. Something like this, where the comment ID is 1234...
<!-- 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>
Note: the for and id attributes are in valid if starting with a number so just prepend alpha characters
doubledee — 2014-07-05T13:11:37-04:00 — #3
Some related questions that you may or may not be able to answer...
1.) Is it a bad design to just want people to vote on one comment at a time like I described?
(With your suggestion above, I could probably make it so people could vote on all Comments at once...)
2.) Would it be better if I had a separate Form for each Comment?
bluedreamer — 2014-07-05T13:44:16-04:00 — #4
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.
doubledee — 2014-07-05T15:31:32-04:00 — #5
Your comments in #2 are my exact concern!!
I agree that i don't think people naturally would want to reviews 150 comments and then click "Submit"
I see this more as someone reading a really good or bad comment and wanting to voice their impression.
Also, how would I handle error messages if I let people vote on numerous comments at once?
And, yes, where would the submit button go?!
Okay, but to be clear....
If I have an article with 227 Comments, you are saying it is okay if my PHP dynamically generates 227 corresponding Forms?! :eek:
Would I have to assign a unique "Form ID" or how would that work?
felgall — 2014-07-05T19:25:21-04:00 — #6
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,
<!-- 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>
doubledee — 2014-07-05T20:24:40-04:00 — #7
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?? :eek:
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!
felgall — 2014-07-05T21:17:53-04:00 — #8
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.
system — 2014-10-08T02:16:50-04:00 — #9
This topic is now closed. New replies are no longer allowed.