> I'm having issues with hidden & checkbox input fields. I have a set > of checkboxes that the user can click. When a user selects a > checkbox, I want jQuery to return the value of that particular > checkbox, plus the value of the hidden form field that is next to it. > > Yet, it's not as easy as I thought it would be to come up with a > solution. Take the following code. > > CHECKBOX FIELDS > <div class="review"> > <input type="hidden" name="data[Request][id]" value="745" > id="RequestId" /> > <input type="checkbox" name="data[Request][review_id]" > id="RequestReviewId" value="1" /> > </div> > > JQUERY > var review = $("#review :checkbox").val(); //VALUE OF CHECKBOX > var rId = > $("input:hidden[name='data[Request][id]']").fieldValue(); > var zero = '0'; > > jQuery.each(rId, function(i, val) { > alert("Index: " + i + " Value: " + val); > }); > > Any assistance is greatly appreciated. >
Maybe something like this? var $review = $("#review :checkbox"); var val1 = $review.val(); var val2 = $review.prev(':hidden').val();