Jump to content

Hide a submit button based on the value in the list string


Recommended Posts

@Alison

You can use JS code to do this.

Here is the example of the code:

<script type="text/javascript">
document.addEventListener('DataPageReady', function () {

 let elem = document.querySelector('input[id^="InsertRecordListStr_Field"]'); //Change the "ListStr_Field" according to your field name
 let button = document.querySelector('td[class^="cbSubmitButtonContainer"]');

 elem.addEventListener('change', function() {
  let elemValues = elem.value.split(',');
  if(elemValues.includes('1')) { // Change '1' value according to value you have as condition
   button.style.display = "none";
  } else {
   button.style.display = "";
  }
 });

});
</script>

You should copy/paste this snippet of code into the footer of your datapage. Make sure that you disabled the HTML editor.

Behind the scenes, list string field uses numbers to identify the values you have chosen.
You need to check, what is the number of the value you want to use to hide submission form and update my code with this value.

Also, find the little APP attached. It contains the datapage with this code - JS_Hide_Submit_Button_ListString_1_0_2019-Jul-04_0816.zip.
Use it as an example.

Link to comment
Share on other sites

  • 1 year later...

I have found out that to make it work whrn Responsive is enabled, the "td" should be changed to "div" when defining the button variable. Please use the following code below:
 

<script type="text/javascript">
document.addEventListener('DataPageReady', function () {

 let elem = document.querySelector('input[id^="InsertRecordListStr_Field"]');
 let button = document.querySelector('div[class^="cbSubmitButtonContainer"]');

 elem.addEventListener('change', function() {
  let elemValue = elem.value.split(',');
  if(elemValue.includes('1')) {
   button.style.display = "none";
  } else {
   button.style.display = "";
  }
 });

});
</script>

 

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...
×
×
  • Create New...