Is it possible for a client script to check for a particular button on a form?

peter_foreman
Tera Guru

For example: I would like to test for the 'Apply Proposed Changes' Button on the Change form when the status changes.

1 ACCEPTED SOLUTION

poyntzj
Kilo Sage

Here is an old function I use to hide buttons for approval resets.


You could use something like this (create it as an onLoad Client script) and your onLoad calls the function as well as setting it.


Then create an onChange Client script that calls the same routine when something triggers the change to a field / status.



function resetRequestApproval() {



      var refs = document.getElementsByTagName("BUTTON");


      if (g_form.getValue('approval') == 'not requested')


      {


              // hide both "Request Reset" and "Reset Approval buttons"


              if (refs) {


                      for (i=0; i < refs.length; i++)


                      {


                              ref = refs[i];


                              buttonphrase = ref.innerHTML;


                              if (buttonphrase == '<span>Request Reset</span>')


                                      ref.style.display = 'none';


                              if (buttonphrase == '<span>Reset Approval</span>')


                                      ref.style.display = 'none';


                      }


              }


      }


      else


      {


              // Hide Reset Approval and show Request Reset


              if (refs) {


                      for (i=0; i < refs.length; i++)


                      {


                              ref = refs[i];


                              buttonphrase = ref.innerHTML;


                              if (buttonphrase == '<span>Request Reset</span>')


                                      ref.style.display = '';


                              if (buttonphrase == '<span>Reset Approval</span>')


                                      ref.style.display = 'none';


                      }


              }


   


      }


}


View solution in original post

6 REPLIES 6

poyntzj
Kilo Sage

Here is an old function I use to hide buttons for approval resets.


You could use something like this (create it as an onLoad Client script) and your onLoad calls the function as well as setting it.


Then create an onChange Client script that calls the same routine when something triggers the change to a field / status.



function resetRequestApproval() {



      var refs = document.getElementsByTagName("BUTTON");


      if (g_form.getValue('approval') == 'not requested')


      {


              // hide both "Request Reset" and "Reset Approval buttons"


              if (refs) {


                      for (i=0; i < refs.length; i++)


                      {


                              ref = refs[i];


                              buttonphrase = ref.innerHTML;


                              if (buttonphrase == '<span>Request Reset</span>')


                                      ref.style.display = 'none';


                              if (buttonphrase == '<span>Reset Approval</span>')


                                      ref.style.display = 'none';


                      }


              }


      }


      else


      {


              // Hide Reset Approval and show Request Reset


              if (refs) {


                      for (i=0; i < refs.length; i++)


                      {


                              ref = refs[i];


                              buttonphrase = ref.innerHTML;


                              if (buttonphrase == '<span>Request Reset</span>')


                                      ref.style.display = '';


                              if (buttonphrase == '<span>Reset Approval</span>')


                                      ref.style.display = 'none';


                      }


              }


   


      }


}


peter_foreman
Tera Guru

Thank you for your responses:


Julian, that is the basics of what I needed.


Thanks


Peter