>  Is there a way to make this dynamic?
>
>  I have ~ 100 lines that need to be written into a table of data which
>  a check box indicating status of a project (complete or not).
>  Each checkbox has an id="check1" or "check2" etc.
>  What I'm looking to do is to trigger a function that submits
>  ProcessThe Data.asp?ID=1 (which is done in the background without a
>  page refresh.
>
>  What you suggested works perfectly for submitting the entire form - I
>  think I want to submit a simple URL and have it process in the
>  background.

Something like this should work:

$(':checkbox[id^=check]').click(function() {
    var num = this.id.match(/\d+$/)[0];
    $.post('ProcessTheData.asp?ID=' + num);
});

Or if you don't want 100+ handlers bound you can use delegation and
bind a handler to your table:

$('#myBigTable').click(function(e) {
    if (e.target.id) {
        var num = e.target.id.match(/check(\d+)$/)[1];
        if (num)
            $.post('ProcessTheData.asp?ID=' + num);
    }
});

Reply via email to