Please note that this code is not tested, I've just wrote it just for demonstration:
This JS script mainly checks whether the selected radio button is a female, then sends a check flag through post to a php file.
In your php file you should check if the total number of woman is already 100; then return a message with the type "exceeded" which will be captured in the script, thus you can add required actions such as hiding the form and adding a custom message.
JS:
<script type="text/javascript">
$('form input[name=female]').on('change', function () {
if ($('input[name=female]:checked', 'form').val() == "female") {
var loader = jQuery('#loader');
loader.fadeIn();
//add aditional post values values here
post_data = {
'check': '1'
};
$.post('processing.php', post_data, function (response) {
if (response.type == "exceeded") {
$('#message').html(response.text);
$("#message").fadeIn();
loader.fadeOut();
//Do more actions here like:
$('form').slideUp();
}
}, 'json');
}
});
</script>
processing.php
<?php
if ($_POST) {
//check if its an ajax request, exit if not
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
$output = json_encode(array(//create JSON data
'type' => 'error',
'text' => 'Sorry Request must be Ajax POST'
));
die($output); //exit script outputting json data
}
$check = filter_var($_POST["check"], FILTER_SANITIZE_NUMBER_INT);
if ($check) {
//check the total nbr of women saved in the database and add it to $total_women
if ($total_women >= 100) {
$output = json_encode(array('type' => 'exceeded', 'text' => 'Max nbr reached'));
die($output);
}
}
}
?>
Cheers!