kpcollier Posted April 12, 2020 Report Share Posted April 12, 2020 Is there a caspio standard way to have an alert box pop up? I have a text field value that has 6 choices, represented by radio buttons. If the user clicks on '6', I am trying to get an alert to pop up. This will just be like a dialog/alert box where the user has to click okay to get back to the form. Can anyone help me out with this? I have tried with some JS, however I am not sure how to implement/call it. var reasonChoice = [@Reason]; if (reasonChoice = "6") { window.alert("Please see update below.") } Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
Hastur Posted April 13, 2020 Report Share Posted April 13, 2020 Hello @kpcollier You can use this code: <script type="text/javascript"> document.addEventListener('DataPageReady', assignAdditionalListeners) function assignAdditionalListeners() { document.querySelector('input[id^="InsertRecordtext_f0"]').addEventListener('change', customAlert); // change ID document.querySelector('input[id^="InsertRecordtext_f1"]').addEventListener('change', customAlert); // change ID document.querySelector('input[id^="InsertRecordtext_f2"]').addEventListener('change', customAlert); // change ID document.querySelector('input[id^="InsertRecordtext_f3"]').addEventListener('change', customAlert); // change ID document.querySelector('input[id^="InsertRecordtext_f4"]').addEventListener('change', customAlert); // change ID document.querySelector('input[id^="InsertRecordtext_f5"]').addEventListener('change', customAlert); // change ID document.removeEventListener('DataPageReady', assignAdditionalListeners) } function customAlert(event) { alert(event.target.value); } </script> You need to place the code in the header of the form. Do not forget to disable the HTML editor in the advanced section of the footer. You need to change the ID according to the name of the field you use. In the Example I have name as "InsertRecordtext_f0". If your field has name "Reason", you should name ID like this - "InsertRecordReason0". 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.