Anyway the joint orient function fits the bill, so here is the main modifications I added to it.
It had two buttons, and ON button and an OFF button. I removed anything in the script referring to the OFF button, and removed the line of code that created he ON button, then I added this code:
// Create button with the toggle command
string $button = `button -label "On" toggle`;
button -edit -command ("toggleButton " + $button) $button;
Note that the first line of code names the button "toggle"
Then I added this procedure:
global proc toggleButton (string $whichButton) {
string $labelA; string $labelB; string $currentLabel;
$labelA = "On";
$labelB = "Off";
$currentLabel = `button -query -label $whichButton`;
if ($currentLabel != $labelA){
button -edit -label $labelA $whichButton;
jsDisplayAxisOnOff 1; // command to toggle on
} else {
button -edit -label $labelB $whichButton;
jsDisplayAxisOnOff 0; // command to toggle off
}
}
The tricky part of this procedure is that it must contain a command for whatever you want to do in your procedure, so as the code stands, you could not just create a generic toggleButton procedure, as the code is written. You be able to do it by passing in the commands as parameters I suppose, but when I am coding, as a general rule, I keep it simple, then later on when I feel energetic, I look for ways to improve the code.
Anyways as it stands, the procedure is imbedded in the jsOrientJointUI script, so it can call the "jsDisplayAxisOnOff 0;"
and "jsDisplayAxisOnOff 1;" without bothering to pass the parameters into the procedure. Maybe I'll get energetic later and write a generic toggleButton procedure that can be outside of the script. . . .
The new script, after my hacking on it I named jsOrientJointUIR
and will provide it for anyone who wants to look at it or try it out. . . .
Maybe someone else will feel energitic before I do and write the toggleButton script so it includes the command parameters . . .

BTW, I tried contacting the original author of this function, as there was an email listed for him, but the email address is evidently out of date. . . .