techguy Posted July 23, 2021 Report Share Posted July 23, 2021 Actually, I think I had copied and pasted and left some brackets.. the code does work with the dropdown... sorry for the confusion.. however still does not submit when I check or uncheck the box with the else if Quote Link to comment Share on other sites More sharing options...
techguy Posted July 23, 2021 Report Share Posted July 23, 2021 As a note, I have responsive turned off since it buggers up the styling if it is on. I have it in a menu space and very specific css requirments. Not sure if the code changes with responsive is OFF Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted July 23, 2021 Report Share Posted July 23, 2021 8 minutes ago, techguy said: As a note, I have responsive turned off since it buggers up the styling if it is on. I have it in a menu space and very specific css requirments. Not sure if the code changes with responsive is OFF Ah I know it now. changing the values on JS will not trigger the eventlistener, you need to explicitly dispatch that event once the value changes. Use this on both the if and else document.getElementById('EditRecordStatusLocation').dispatchEvent(new Event('change')); Here's my script <script type="text/javascript"> document.getElementById("EditRecordyess").addEventListener('change', function(event) { if (document.getElementById("EditRecordyess").checked==true){ document.getElementById("cbParamVirtual1").value='Online'; document.getElementById('cbParamVirtual1').dispatchEvent(new Event('change')); } else if (document.getElementById("EditRecordyess").checked==false){ document.getElementById("cbParamVirtual1").value='Off'; document.getElementById('cbParamVirtual1').dispatchEvent(new Event('change')); } }); </script> <script type="text/javascript"> document.getElementById("cbParamVirtual1").addEventListener('change', function myFunction(event) { // submit the form if an value is selected setTimeout('document.forms["caspioform"].submit()',1000); }); </script> This submits mine upon checking or unchecking Quote Link to comment Share on other sites More sharing options...
techguy Posted July 23, 2021 Report Share Posted July 23, 2021 Bravo!!! You are amazing! a little more maybe.... 1. Is there a way now in this script on the dropdown, when the selected option is 'Off' it also turns the checkbox off (unchecks it?) 2. does the page refresh on submit on refresh because it is a single record update page? Should I try to make this work with another page type. The refreshing of the entire page sucks, lol Thank you soooooo much. a few little tweaks hopefully and one less task!!! Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted July 23, 2021 Report Share Posted July 23, 2021 21 minutes ago, techguy said: Bravo!!! You are amazing! a little more maybe.... 1. Is there a way now in this script on the dropdown, when the selected option is 'Off' it also turns the checkbox off (unchecks it?) 2. does the page refresh on submit on refresh because it is a single record update page? Should I try to make this work with another page type. The refreshing of the entire page sucks, lol Thank you soooooo much. a few little tweaks hopefully and one less task!!! what field is that dropdown? Is it the status location or an entirely different one not used in the script? 2. No, it ALWAYS refreshed upon submission of form. It's an HTML thing. Quote Link to comment Share on other sites More sharing options...
techguy Posted July 23, 2021 Report Share Posted July 23, 2021 The dropdown is the one called StatusLocation - all on same script and datapage on the refresh.. so if I update, then it will not refresh the whole page? If I submit form it does? Quote Link to comment Share on other sites More sharing options...
techguy Posted July 23, 2021 Report Share Posted July 23, 2021 so maybe I can make a report page work for me.. I assume I would need to change the script for datapage type , but my report pages when updated do not refresh.. do you think that might help? Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted July 23, 2021 Report Share Posted July 23, 2021 14 minutes ago, techguy said: The dropdown is the one called StatusLocation - all on same script and datapage on the refresh.. so if I update, then it will not refresh the whole page? If I submit form it does? Here;s an updated code Virtual 2 is my dropdown You can put the dispatch event after the if elses instead so you'll have shorter code 2nd script tag is what I added <script type="text/javascript"> document.getElementById("EditRecordyess").addEventListener('change', function(event) { if (document.getElementById("EditRecordyess").checked==true){ document.getElementById("cbParamVirtual2").value='Online'; } else if (document.getElementById("EditRecordyess").checked==false){ document.getElementById("cbParamVirtual2").value='Off'; } document.getElementById('cbParamVirtual2').dispatchEvent(new Event('change')); }); </script> <script type="text/javascript"> document.getElementById('cbParamVirtual2').addEventListener('change', function(event) { if (document.getElementById('cbParamVirtual2').value=='Online'){ document.getElementById("EditRecordyess").checked=true; } else if (document.getElementById('cbParamVirtual2').value=='Off'){ document.getElementById("EditRecordyess").checked=false; } document.getElementById("EditRecordyess").dispatchEvent(new Event('change')); }); </script> <script type="text/javascript"> document.getElementById("cbParamVirtual2").addEventListener('change', function myFunction(event) { // submit the form if an value is selected setTimeout('document.forms["caspioform"].submit()',1000); }); </script> No Update and Submit works as "Submit Form" tabular reports is MUCH harder to do custom coding on Quote Link to comment Share on other sites More sharing options...
kpcollier Posted September 30, 2021 Report Share Posted September 30, 2021 I am using a tabular report where the search form is above the results table, not on a separate page. The script above works, as it is submitting the search button when any dropdown value is selected. However, upon loading the new results, the search form is no longer on top of the results. It is missing, with no way to get back to it unless I reload the page. Anyone have any ideas on how to fix this? I'd like to always keep the search form above the results page. 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.