function displayRadioButtonScript($target, $tablecell = false) { $returnStr = '<script type="text/javascript">$( document ).ready(function() {'; // not allowing deselect if (Config::allowRadioButtonUnselect() == false) { if ($tablecell) { $returnStr .= '$("#cell' . $target . '").mousedown(function (e){ $("#' . $target . '").prop("checked", true); $("#' . $target . '").change(); return false; });'; } } else { $returnStr .= 'var radioChecked' . $target . '; $("#' . $target . '").mousedown(function (e) { if ($(this).prop("checked") == true) { radioChecked' . $target . ' = true; } else { radioChecked' . $target . ' = false; } return true; }); $("#' . $target . '").click(function (e) { if (radioChecked' . $target . ') { $(this).prop("checked", false); } else { $(this).prop("checked", true); } }); $("label[for=\'' . $target . '\']").mousedown(function (e){ if ($(e.target).hasClass("uscic-radiobutton")) { } else { return true; // inline field OR individual dk/rf/na, so prevent click } radioChecked' . $target . ' = $(\'#' . $target . '\').prop(\'checked\'); if (radioChecked' . $target . ') { $("#' . $target . '").prop("checked", false); } else { $("#' . $target . '").prop("checked", true); } $("#' . $target . '").change(); return false; // prevent bubbling to table cell level }); '; // if in table if ($tablecell) { $returnStr .= '$("#cell' . $target . '").mousedown(function (e){ radioChecked' . $target . ' = $(\'#' . $target . '\').prop(\'checked\'); if (radioChecked' . $target . ') { $("#' . $target . '").prop("checked", false); } else { $("#' . $target . '").prop("checked", true); } $("#' . $target . '").change(); return false; });'; } } $returnStr .= '});</script>'; return minifyScript($returnStr); }