Skip to content

On Change Client Script : Display Section based on State #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Client Scripts/Display Section on State/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Display Section Based on State

## Overview
This client script dynamically displays specific sections on a form based on the selected State field value. It improves user experience by hiding or showing relevant sections as needed.

## How It Works
- When the State field changes, the script checks the new value.
- For Example, if the state is changed to "Resolved", the Resolution Section becomes visible.
- For other states, the section remains hidden.
10 changes: 10 additions & 0 deletions Client Scripts/Display Section on State/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

if (newValue == 6) //State on which section needs to be displayed
g_form.setSectionDisplay('resolution_information', true); //Section which needs to be display
else
g_form.setSectionDisplay('resolution_information', false);
}
Loading