DRAhmed Posted October 11, 2022 Report Share Posted October 11, 2022 is there a way to make a checkbox uncheck-able after being checked i tried using a virtual field and a disable rule but in this case the check doesn't get registered at all after checking the box , it should be uncheck-able but still register in the table Quote Link to comment Share on other sites More sharing options...
1 futurist Posted October 11, 2022 Report Share Posted October 11, 2022 Hi @DRAhmed, You can use the following script: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { const selectElement = document.querySelector('#InsertRecordYesNo'); selectElement.addEventListener('change', (event) => { if(selectElement.checked = true){ document.querySelector("#InsertRecordYesNo").disabled = true; } }); }); </script> Make sure to change "YesNo" in "InsertRecordYesNo" to your actual Yes/No field name. One question though. What if the checkbox is checked to begin with? DRAhmed 1 Quote Link to comment Share on other sites More sharing options...
1 futurist Posted October 12, 2022 Report Share Posted October 12, 2022 Just to add to this, you can actually do this using Rules. You can put your Yes/No field in its own section, So that when you set up the Rule, you use the Yes/No field for the criteria, but use its section for the action: DRAhmed 1 Quote Link to comment Share on other sites More sharing options...
1 Tubby Posted October 15, 2022 Report Share Posted October 15, 2022 9 hours ago, DRAhmed said: when i do like that the check doesnt get registered in the source table Yes, because fields that are disabled by Rules tends to not get submitted. What you can do is this: Create a Virtual field that will act as your Checkbox. Make your Actual Yes/No field's form element as Calculated Value and make it hidden(Advanced tab) Use a CASE statement to get the value from the Virtual field:CASE WHEN [@cbParamVirtual1] = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END Then use the suggestion of @futurist to disable the Virtual checkbox. DO NOT include the actual Yes/No field in the section that you are going to disable. It should only contain the virtual checkbox. futurist and DRAhmed 2 Quote Link to comment Share on other sites More sharing options...
1 Tubby Posted October 18, 2022 Report Share Posted October 18, 2022 9 hours ago, DRAhmed said: i did like you said but i recieve Values in one or more fields are invalid. Oh, unhide the calculated value and check if it is getting any value. it might be getting NULL. if yes, try using single quotes for the virtual field.CASE WHEN '[@cbParamVirtual1]' = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END Or check your virtual field's "value when checked" and see if you have Y there. You might have a different value than what I use. DRAhmed 1 Quote Link to comment Share on other sites More sharing options...
0 DRAhmed Posted October 15, 2022 Author Report Share Posted October 15, 2022 On 10/12/2022 at 11:32 PM, futurist said: Just to add to this, you can actually do this using Rules. You can put your Yes/No field in its own section, So that when you set up the Rule, you use the Yes/No field for the criteria, but use its section for the action: when i do like that the check doesnt get registered in the source table Quote Link to comment Share on other sites More sharing options...
0 DRAhmed Posted October 18, 2022 Author Report Share Posted October 18, 2022 On 10/16/2022 at 12:24 AM, Tubby said: Yes, because fields that are disabled by Rules tends to not get submitted. What you can do is this: Create a Virtual field that will act as your Checkbox. Make your Actual Yes/No field's form element as Calculated Value and make it hidden(Advanced tab) Use a CASE statement to get the value from the Virtual field:CASE WHEN [@cbParamVirtual1] = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END Then use the suggestion of @futurist to disable the Virtual checkbox. DO NOT include the actual Yes/No field in the section that you are going to disable. It should only contain the virtual checkbox. i did like you said but i recieve Values in one or more fields are invalid. Quote Link to comment Share on other sites More sharing options...
0 DRAhmed Posted October 19, 2022 Author Report Share Posted October 19, 2022 7 hours ago, Tubby said: Oh, unhide the calculated value and check if it is getting any value. it might be getting NULL. if yes, try using single quotes for the virtual field.CASE WHEN '[@cbParamVirtual1]' = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END Or check your virtual field's "value when checked" and see if you have Y there. You might have a different value than what I use. i did like this , CASE WHEN '[@cbParamVirtual1]' = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END it worked but it still didnt register in the table Quote Link to comment Share on other sites More sharing options...
0 Tubby Posted October 20, 2022 Report Share Posted October 20, 2022 On 10/18/2022 at 7:43 PM, DRAhmed said: i did like this , CASE WHEN '[@cbParamVirtual1]' = 'Y' THEN CAST('1' AS BIT) ELSE CAST('0' AS BIT) END it worked but it still didnt register in the table By it worked but didnt register in the table, do you mean that when you unhid the actual field and tested if the check from the virtual field is getting cascaded, it did, but it did not save upon submission? Did you put the Virtual field in a separate section as I mentioned? Basically what I had in mind is something like this: Section 2 VirtualField (Checkbox) Section 3 Yes/NoField(Calculated Value) Quote Link to comment Share on other sites More sharing options...
0 DRAhmed Posted October 22, 2022 Author Report Share Posted October 22, 2022 On 10/20/2022 at 5:35 PM, Tubby said: By it worked but didnt register in the table, do you mean that when you unhid the actual field and tested if the check from the virtual field is getting cascaded, it did, but it did not save upon submission? Did you put the Virtual field in a separate section as I mentioned? Basically what I had in mind is something like this: Section 2 VirtualField (Checkbox) Section 3 Yes/NoField(Calculated Value) so i tested some things and here is what i found everything works 1) if the virtual field has a rule of getting disabled when checked , the calculated value results in yes but doesnt get saved upon submission 2) if i remove the rule , it gets saved but this isn't what i want Quote Link to comment Share on other sites More sharing options...
0 Tubby Posted October 25, 2022 Report Share Posted October 25, 2022 On 10/22/2022 at 1:19 AM, DRAhmed said: so i tested some things and here is what i found everything works 1) if the virtual field has a rule of getting disabled when checked , the calculated value results in yes but doesnt get saved upon submission 2) if i remove the rule , it gets saved but this isn't what i want Sorry, yes I tried creating it back and it isnt working. Not sure what went wrong as this is a known workaround of mine. I don't know what else to try. Maybe anyone else has some other workarounds. DRAhmed 1 Quote Link to comment Share on other sites More sharing options...
0 DRAhmed Posted October 29, 2022 Author Report Share Posted October 29, 2022 On 10/26/2022 at 1:34 AM, Tubby said: Sorry, yes I tried creating it back and it isnt working. Not sure what went wrong as this is a known workaround of mine. I don't know what else to try. Maybe anyone else has some other workarounds. thank you very much for trying Quote Link to comment Share on other sites More sharing options...
Question
DRAhmed
is there a way to make a checkbox uncheck-able after being checked
i tried using a virtual field and a disable rule but in this case the check doesn't get registered at all
after checking the box , it should be uncheck-able but still register in the table
Link to comment
Share on other sites
11 answers to this question
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.