brown2005 Posted November 23, 2011 Share Posted November 23, 2011 $(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. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted November 23, 2011 Share Posted November 23, 2011 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'); } }); Quote Link to comment Share on other sites More sharing options...
brown2005 Posted November 23, 2011 Author Share Posted November 23, 2011 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(); } }); }); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.