ChrisV Posted October 25, 2021 Report Share Posted October 25, 2021 Hello, I have a checkbox in a detail page. I want to use the checkbox value in a script in the footer of that page. The problem is that it is always giving me the checked value even when not checked. Here is my script: <script> document.getElementsByName('Mod0EditRecord')[0].onmouseover = function(){ var dropdown = document.getElementById('cbParamVirtual4').value; var vendu = document.getElementById('EditRecordOKpourVendu').value; if (vendu == "Y") {dropdown = "7"; } document.getElementById('EditRecordstage_id').value = dropdown; }; </script> I have no problem to get the Virtual4 value, it is a dropdown menu. Thanks for your help Quote Link to comment Share on other sites More sharing options...
CoopperBackpack Posted October 25, 2021 Report Share Posted October 25, 2021 Hello @ChrisV, It looks like the Yes/No field always has the "Y" value even when the checkbox is not checked: Please try to check the 'checked' attribute instead. If 'checked' is equal to 'true', then checkbox is checked. <script> document.getElementsByName('Mod0EditRecord')[0].onmouseover = function(){ var dropdown = document.getElementById('cbParamVirtual4').value; var vendu = document.getElementById('EditRecordOKpourVendu'); if (vendu.checked === true) {dropdown = "7"; } document.getElementById('EditRecordstage_id').value = dropdown; }; </script> Hope this helps. Quote Link to comment Share on other sites More sharing options...
ChrisV Posted October 26, 2021 Author Report Share Posted October 26, 2021 Hello @CoopperBackpack , Thanks for your reply and for leading me in the right way, this helped a lot. I had to make it a little bit different to make it works. Here is the working solution: <script> document.getElementsByName('Mod0EditRecord')[0].onmouseover = function(){ var dropdown = document.getElementById('cbParamVirtual4').value; if (document.getElementById('EditRecordOKpourVendu').checked == true) {dropdown = "7"; } document.getElementById('EditRecordstage_id').value = dropdown; }; </script> Thanks and best regards Kurumi and DesiLogi 2 Quote Link to comment Share on other sites More sharing options...
RuisiHansamu Posted August 16, 2023 Report Share Posted August 16, 2023 You can also check here for more tips: 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.