Jump to content

Custom Update Button


Recommended Posts

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?

Link to comment
Share on other sites

  • 5 months later...

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 }))
})

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...