Jump to content

help with this code


brown2005

Recommended Posts

$(document).ready(function() {

$.ajax({
	type: "GET",
	url: "ajax-search.php",
	success: function(server_response){
		$('#results').html(server_response).show();
	}
});

$("#blocked").click(function() {

	var dataString = 'blocked=1';

	$.ajax({
		type: "GET",
		url: "ajax-search.php",
		data: dataString,		
		success: function(server_response){
			$('#results').html(server_response).show();
		}
	});

});

});

 

I have the above code which works fine.. the results are loaded up on the load of the website. Then when I tick the checkbox it takes away results that have been blocked, but what i wanna do is when i on tick the box to remove the blocked=1 and then get the results.

 

thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/251676-help-with-this-code/
Share on other sites

Are you saying that you want to test if the checkbox is selected or not? If so you would use the following example:

 

$("#blocked").click(function() {
if($(this).is(':checked')) {
  alert('checked');
}
else {
  alert('unchecked');
}
});

Link to comment
https://forums.phpfreaks.com/topic/251676-help-with-this-code/#findComment-1290716
Share on other sites

I have the code doing what I want, when i tick say the block checkbox it removes blocked results then untick it adds them back. This works for the seen before checkbox two, but I want to combine the two so that if they are both checked will remove blocked and seen before results.

 

Thanks in advance.

 

$(document).ready(function() {

$.ajax({
type: "GET",
url: "ajax-search.php",
success: function(server_response){
$('#results').html(server_response).show();
}
});

$("#blocked").click(function(){
  
if($('#blocked').is(':checked')){

var dataString = 'blocked=1'; 

}else{

var dataString = 'blocked=0';

}

$.ajax({
type: "GET",
url: "ajax-search.php",
data: dataString, 
success: function(server_response){
$('#results').html(server_response).show();
}
});

});

$("#seen").click(function(){
  
if($('#seen').is(':checked')){

var dataString = 'seen=1'; 

}else{

var dataString = 'seen=0';

}

$.ajax({
type: "GET",
url: "ajax-search.php",
data: dataString, 
success: function(server_response){
$('#results').html(server_response).show();
}
});

});

});

Link to comment
https://forums.phpfreaks.com/topic/251676-help-with-this-code/#findComment-1290722
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.