MarkMayhrai Posted October 21, 2021 Report Share Posted October 21, 2021 Hello, I need help please. I wish to have a custom button displayed on a update page if a checkbox is blank. Also, need to have the default update button hidden and not accessible. Finally I would like the custom button to check the checkbox and submit the update to the record Is this possible with JavaScript? Quote Link to comment Share on other sites More sharing options...
Volomeister Posted April 7, 2022 Report Share Posted April 7, 2022 Hi Mark! Here is code snippet I wrote that might facilitate such a scenario. const mainUpdateButton = document.querySelector('.cbUpdateButton'); mainUpdateButton.style.display = 'none'; mainUpdateButton.insertAdjacentHTML('beforebegin', `<div class="cbUpdateButtonContainer"><input id="newUpdateButton" value="Update" class="cbUpdateButton"></div>`); document.querySelector('#newUpdateButton').addEventListener('click', _=> { document.querySelector('[type="checkbox"]').checked = true; mainUpdateButton.dispatchEvent(new Event('click', { 'bubbles': true })) }) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.