Link to home
Start Free TrialLog in
Avatar of Michelle Jackson
Michelle Jackson

asked on

Sending Checkbox Status

Trying to send checkbox state to PHP page using Ajax. I am able to send he value of the element but I also need to send the state of the button that will determine if the data is added or deleted from the database. Here is what I have.
<script>

 $(document).on('click', '.favorite-resource-checkbox', function(){  
            var resourceValues = $( this ).val();
		    var user = "<?php echo $user_id; ?>";
	 		var id = $(this).attr('id');
           
           $.ajax({  
                url:"file.php",  
                method:"POST",  
                data:{value: resourceValues , user: user},  
                dataType:"text",  
                success:function(data)  
                {  
                     alert(data);  
                    
                }  
           })  
      });		
	
</script>	

Open in new window


Thanks
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michelle Jackson
Michelle Jackson

ASKER

Thank you all three solutions worked.