I have in my document 2 checkbox arrays. One is engines[] and one is searchId[].
$("input:checkbox[@name='searchId[]']:checked").each(function() i use this to capture all the values from the searchId[] checkboxes (only if checked). $("input:checkbox[@name='engines[]']:checked").each(function() same thing for engines
the problem is that it the selector gets all the checked checkboxes in the document regardless of their name. How can I make it get only the array I wish to get?
some code for a better understanding:
$("#startSearch").live("click", function(event){ //event.preventDefault(); $("input:checkbox[@name='searchId']:checked").each(function(){
$.getJSON("startsearch.php",{searchId: $(this).val()},function(data){
alert($(this).val());
$('#status_' + $(this).val()).text(data.status);
$('#results_' + $(this).val()).text(data.results);
$('#date_' + $(this).val()).text(data.date);
$('#totalResults_' + $(this).val()).text(data.totalResults);
});
});
});
$("#submit").click(function(event){ event.preventDefault();
$("input[@name='engines[]']:checked").each(function(){
$.getJSON( "addsearch.php", { inputString: $('#inputString').val(),searchString: $('#searchString').val(), engine: $(this).val() }, function(data){
//$('#searchTable tbody tr:first').empty();
var row = '<tr><td><span id ="status_'+data.id+'">'+data.status+'</span></td>'+
'<td>'+data.search+'</td>'+
'<td>'+data.category+'</td>'+
'<td>'+data.engine+'</td>'+
'<td><span id = "results_"'+data.id+'">0</span></td>'+
'<td><span id ="date_'+data.id+'">'+data.date+'</span></td>'+
'<td><span id ="totalResults_'+data.id+'">0</span></td>'+
'<td style="width: 96px;"><div class="actions"><ul>'+
'<li><input class="radio" name="searchId[]" type="checkbox" value="'+data.id+'" /></li>'+
'<li><a class="action1" href="#">1</a></li>'+
'<li><a class="action4" href="#">4</a></li>'+
'</ul></div></td>';
$('#searchTable tbody').after(row);
});
});
});
});