-1

Possible Duplicate:
Select values of checkbox group with jQuery

I'm looking to select a checkbox by value using JQuery. I don't want to loop through all of the values to see if the value is in the collection. I may have a bunch of checkboxes so this would only slow down the whole process. Thanks in advance.


To clarify more I was looking was this. I have a dropdown which contain aggregate rooms. Each of these rooms are made up up multiple singular rooms. So we may have in the dropdown something like

Aggregate Room AB Aggregate Room BC Aggregate Room ABCD

below this is a list of checkboxes that represent a singular room

Room A Room B Room C Room D

What I was trying to accomplish was to have the bottom checkboxes selected when the top aggregate rooms were selected. So if I picked Aggregate Room AB the checkboxes below would pick Room A and Room B.

My solution was as follows: http://jsfiddle.net/xkXSx/43/

Thanks for the kind responses.

Community
  • 1
  • 1
Dale
  • 1,613
  • 4
  • 22
  • 42
  • Could you please clarify exactly what you want, possibly with code or pseudo code? – Chris Aug 03 '12 at 15:51
  • So you think some magic JQuery will not have to do the loop anyway? – musefan Aug 03 '12 at 15:51
  • Based on your question, I'm not sure if http://stackoverflow.com/questions/416752/select-values-of-checkbox-group-with-jquery?rq=1 is a duplicate. But I'm guessing it might be. – AlexMA Aug 03 '12 at 15:52

1 Answers1

7
$('input:checkbox[value="your_value"]').prop('checked', true);​
Mark Pieszak - Trilon.io
  • 61,391
  • 14
  • 82
  • 96
jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160