Ruby check_boxes select/unselect all problem

S

sig_UVA

I have the three erb check_boxes below:

Patient #1<%= check_box("patient", '1', {}, "yes","no") %></br>
Patient #2<%= check_box("patient", '2', {}, "yes","no") %></br>
Patient #4<%= check_box("patient", '4', {}, "yes","no") %></br>


The HTML output looks like this:

Patient #1<input id="patient_1" name="patient[1]" type="checkbox"
value="yes" /><input name="patient[1]" type="hidden" value="no" /></br>

Patient #2<input id="patient_2" name="patient[2]" type="checkbox"
value="yes" /><input name="patient[2]" type="hidden" value="no" /></br>

Patient #4<input id="patient_4" name="patient[4]" type="checkbox"
value="yes" /><input name="patient[4]" type="hidden" value="no" /></br>


I want to create a button(s) to check all/uncheck all the check_boxes
if clicked by the user. I was thinking I had to use javascript to do
this, but the erb is appending the value to the name in the HTML
output. What this does is prevent my javascript from recognizing these
check_boxes as a collection named "patient".

What can I do remedy in this? If I could handly all of this with Ruby,
that'd be great, but I don't know how yet.

Thank you for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top