Skip to main content
Question

Button to toggle a checkbox in report

  • April 24, 2018
  • 0 replies
  • 357 views

I have a report with a checkbox.  I would like to create a button on the report that would toggle the checkbox on or off, depending on it's current status.  I would like the toggle button to change labels (ie. True or False) based on the current value of the checkbox.  Finally, I'd like to have the report stay on the screen.  It can refresh, but I'd prefer it to remain at the report. 

This seems to be beyond my skill level.  Can anyone help me create this?

This topic has been closed for replies.

  • Registered
  • April 25, 2018
Like this?


  • Author
  • Registered
  • August 24, 2018

My current issue is that the button does not seem to work consistently.  It will toggle the checkbox the first time I click it, but will not toggle it on subsequent clicks.  Below is my code.  Any Ideas?
 
var text XXX = If([MD Approval (2)]=false,"true",
[MD Approval (2)]=true,"false");

var text URL =
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_87=" & $XXX & "&apptoken=XXXXXXXXXXXXXX";

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});" & "void(0);"


either of these will work. The issue is that true and false are not text strings, they are boolean so they do not go in quotes.

var text XXX = If([MD Approval (2)]=false, true, false);

var text XXX = not [MD Approval (2)];

  • Author
  • Registered
  • August 24, 2018
I had to change the "var text XXX" to "var bool XXX", otherwise it kept popping an error.  But this still doesn't solve my issue.  I hit the button and it toggled the checkbox.  I tried again and it toggled it successfully, third, fourth and fifth, it did not. 

Can you post your complete code.  It should work.

  • Author
  • Registered
  • August 24, 2018

Here you go.

var bool XXX = not [MD Approval (2)];

var text URL =
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_87=" & $XXX & "&apptoken=XXXXXXXXXXX";

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});" & "void(0);"


see if this works for the javascript

"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});"

  • Author
  • Registered
  • August 24, 2018

Yeah, it didn't like that.  When I replaced my javascript code with this, I got a blank page that just says "[object Object]". 

I tested this and could not get it to fail.  I'm not sure  what else to suggest.  Any chance you were clicking too fast before the page got a chance to refresh

var bool XXX = not [checkbox];

var text URL =
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_26=" & $XXX ;

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});" & "void(0);"


Forum|alt.badge.img+17
  • Community Moderator
  • August 31, 2018
Hi Todd,

Another alternative that might be helpful for checking the status of the checkbox is to instead use the numeric value that the checkbox fields utilize. 1 for True and 0 for false. So something like. 

var numeric XXX = If([Checkbox]=1, 0,1);

var text URL =
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_26=" & $XXX ;

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});" & "void(0);"

That way you are pushing the numeric value into your checkbox field to request the change which might process differently from the not syntax.