views:

22

answers:

1
$("#submit_js").click(function() {

    $.post(
        "user_submit.php", 
        {score: $('input[name=vote]:checked').val() }, 
        function(data){
            $("#ques"+qn).hide();
            ++qn;
            $("#ques"+qn).show();
        });
    });

the above jquery function posts some value to the user_submit.php file. what i am doing here is i pre-load 10 divs and cycle through them through the callback function.

the problem is for

{score: $('input[name=vote]:checked').val() }, 

i want to be able to select the input values in a particular div. is it possible.

To be more clear, I want to first select a div by id and then select the checked inputs inside that div. I know it is possible. Just need help with the syntax.

+1  A: 

Change:

{score: $('input[name=vote]:checked').val() }, 

to

{score: $('#container-div').find('input[name=vote]:checked').val() }, 
K Prime
it can also be written as `{score: $('input[name=vote]:checked', '#container-div').val() }, `
Livingston Samuel
@Livingston - When using context, it is better to pass in the DOM Node, or jQuery object (for the second param), rather than a string; otherwise it's about equivalent to `$(context).find()`
K Prime
@K Prime - Yeah you're right, thanks
Livingston Samuel