Alison Posted July 4, 2019 Report Share Posted July 4, 2019 Hi. How can I hide a submit button based on the value I selected in a list string dropdown field? Quote Link to comment Share on other sites More sharing options...
Hastur Posted July 4, 2019 Report Share Posted July 4, 2019 @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. Quote Link to comment Share on other sites More sharing options...
Alison Posted October 2, 2020 Author Report Share Posted October 2, 2020 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> KG360 1 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.