diff --git a/lam/lib/html.inc b/lam/lib/html.inc
index d9306d06f..3c110c534 100644
--- a/lam/lib/html.inc
+++ b/lam/lib/html.inc
@@ -1642,20 +1642,13 @@ class htmlRadio extends htmlElement {
elseif (!empty($showHideOnchange)) {
$onchange = ' onchange="' . $showHideOnchange . '"';
}
- $onClick = 'onClick="
- jQuery(\'input[name=' . $this->name . ']\').prop(\'checked\', false);
- jQuery(\'#' . $this->name . $counter . '\').prop(\'checked\', true);
- jQuery(\'#' . $this->name . $counter . '\').trigger(\'change\');
- "';
- if ($this->isEnabled === false) {
- $onClick = '';
- }
- echo '
';
+ echo '
';
$selected = '';
if ($value == $this->selectedElement) {
$selected = ' checked';
}
- echo ' ' . $label;
+ echo ' ';
+ echo '';
echo '
';
$counter++;
}
@@ -1712,15 +1705,15 @@ class htmlRadio extends htmlElement {
// build Java script to show/hide depending fields
foreach ($values as $val) {
// build onChange listener
- $onChange .= 'if (jQuery(\'#' . $this->name . $counter . '\').val() == \'' . $val . '\') {';
+ $onChange .= 'if (document.getElementById(\'' . $this->name . $counter . '\').value == \'' . $val . '\') {';
if (isset($this->tableRowsToShow[$val])) {
for ($i = 0; $i < sizeof($this->tableRowsToShow[$val]); $i++) {
- $onChange .= 'jQuery(\'#' . $this->tableRowsToShow[$val][$i] . '\').closest(\'' . $selector . '\').removeClass(\'hidden\');';
+ $onChange .= 'document.getElementById(\'' . $this->tableRowsToShow[$val][$i] . '\').closest(\'' . $selector . '\').classList.remove(\'hidden\');';
}
}
if (isset($this->tableRowsToHide[$val])) {
for ($i = 0; $i < sizeof($this->tableRowsToHide[$val]); $i++) {
- $onChange .= 'jQuery(\'#' . $this->tableRowsToHide[$val][$i] . '\').closest(\'' . $selector . '\').addClass(\'hidden\');';
+ $onChange .= 'document.getElementById(\'' . $this->tableRowsToHide[$val][$i] . '\').closest(\'' . $selector . '\').classList.add(\'hidden\');';
}
}
$onChange .= '};';
@@ -1731,17 +1724,15 @@ class htmlRadio extends htmlElement {
private function printInitialState() {
$selector = $this->getShowHideSelector();
// build script to set initial state
- $script = '';
@@ -2014,7 +2005,7 @@ class htmlInputCheckbox extends htmlElement {
}
$onChange .= '};';
// build script to set initial state
- $script = '';
}
diff --git a/lam/tests/design/designExamples.php b/lam/tests/design/designExamples.php
index 741a54916..131f17202 100644
--- a/lam/tests/design/designExamples.php
+++ b/lam/tests/design/designExamples.php
@@ -378,12 +378,36 @@
$row->add(new htmlSpacer(null, '3rem'));
+$showHideRadio = new htmlResponsiveRadio('Show/hide radio', 'showHideRadio', $showHideOptions, 'input2');
+$showHideRadio->setTableRowsToShow([
+ 'input1' => ['showHideRadio_i1'],
+ 'input2' => ['showHideRadio_i2'],
+ 'both' => ['showHideRadio_i1', 'showHideRadio_i2'],
+]);
+$showHideRadio->setTableRowsToHide([
+ 'input1' => ['showHideRadio_i2'],
+ 'input2' => ['showHideRadio_i1'],
+ 'both' => [],
+]);
+$row->add($showHideRadio);
+$row->add(new htmlResponsiveInputField('Input 1', 'showHideRadio_i1', ''));
+$row->add(new htmlResponsiveInputField('Input 2', 'showHideRadio_i2', ''));
+
+$row->add(new htmlSpacer(null, '3rem'));
+
$showHideCheckbox = new htmlResponsiveInputCheckbox('showHideCheckbox', false, 'Show/hide checkbox');
$showHideCheckbox->setTableRowsToShow(['showHideCheckbox_i1']);
$showHideCheckbox->setTableRowsToHide(['showHideCheckbox_i2']);
+$showHideCheckbox->setElementsToEnable(['showHideCheckbox_ie']);
+$showHideCheckbox->setElementsToDisable(['showHideCheckbox_id']);
$row->add($showHideCheckbox);
$row->add(new htmlResponsiveInputField('Input 1', 'showHideCheckbox_i1', ''));
$row->add(new htmlResponsiveInputField('Input 2', 'showHideCheckbox_i2', ''));
+$row->addVerticalSpacer('0.5rem');
+$row->add(new htmlResponsiveInputField('Enabled on checked', 'showHideCheckbox_ie', ''));
+$row->add(new htmlResponsiveInputField('Disabled on checked', 'showHideCheckbox_id', ''));
+
+$row->add(new htmlSpacer(null, '3rem'));
$row->add(new htmlSpacer(null, '20rem'));