Skip to content

Instantly share code, notes, and snippets.

View guidoeffe's full-sized avatar
🎯
Focusing

Guido Fiamozzi guidoeffe

🎯
Focusing
View GitHub Profile
@guidoeffe
guidoeffe / wpcf7_checkbox.js
Last active March 8, 2021 16:51
CF7 limit number of choises in checkboxes
jQuery(function(){
limitCheck('Q3',2);
limitCheck('Q4',3);
limitCheck('Q9',2);
limitCheck('Q12',4);
function limitCheck(idElement,maxChoises ){
var checkboxes = jQuery('#'+idElement+' input[type="checkbox"]');
checkboxes.change(function(){
var current = checkboxes.filter(':checked').length;
checkboxes.filter(':not(:checked)').prop('disabled', current >= maxChoises);
@guidoeffe
guidoeffe / create_dynamic_variables_fom_post.php
Last active September 12, 2019 15:44
My way to create php array and variables from a json post
<?php
$post_string = file_get_contents("php://input");
if (!empty($post_string))
$post_data= json_decode($post_string, true);
}
if (isset($post_data) and is_array($post_data)){
foreach($post_data as $post_key => $post_value){
${str_name($post_key)} = $post_value;
if (is_array($post_value)){