Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Buton Save - Show or Hidden
Buton Save - Show or Hidden
Good evening. How do I make it so that when editing a form, the 'save' button is shown or hidden based on a field called 'approved' (Yes/No)? If it is 'Yes', hide the save button; if it is 'No', then show the save button. The above is to protect the data. I appreciate your help.
-
- nuBuilder Team
- Posts: 4291
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Buton Save - Show or Hidden
Hi,
In the form's Custom Code, add this JavaScript:
If the "approved" field's ID differs from 'approved', adjust the code accordingly to match the actual ID.
In the form's Custom Code, add this JavaScript:
Code: Select all
// Function to toggle the visibility of the Save button based on 'approved' checkbox state
function toggleSaveButton() {
var isApproved = nuGetValue('approved'); // Retrieves true if checked, false otherwise
// If 'approved' is checked (true), hide the Save button; otherwise, show it
nuShow('nuSaveButton', isApproved); // Second parameter 'true' hides the element
}
// Execute the function when the form loads
toggleSaveButton();
// Also execute the function when the 'approved' checkbox state changes
$('#approved').change(function() {
toggleSaveButton();
});
