Announcement

Collapse
No announcement yet.

Dynamically change custom button labels

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically change custom button labels

    Hi All,

    It seem that this is an issue for many, where they cannot change the text on a custom button when used to toggle things like filters.

    PHP buttons - I cannot see any answers to peoples dilemmas, only suggestions to use a javascript button - but that is way past me at this stage.

    So can you add a macro to change button text?

    Tony

  • #2
    fiscal

    You can create two (or more) buttons and hide the ones that don't apply in a given situation. For example, say I have a button that uploads a file for a given record and the label is "upload file". Once that record has an uploaded file registered with it, if that record is then edited, I want the button to say "delete uploaded file" instead of "upload file".

    So, I have 2 buttons on a form (used to edit / add a new "master" record) - an upload one (uploadfile) and a delete one (deletefile). On the form's onLoad event I have:

    Code:
    if (trim({TSLink}) == '') {
    	{TSLink} = "No file uploaded.";
    	sc_btn_display('uploadfile', 'on');
    	sc_btn_display('deletefile', 'off');
    } else {
    	{TSLink} = '<a href="' . [fp] . {SignedTimesheet} . '" target="_blank">' . {SignedTimesheet} . '</a>';
    	sc_btn_display('deletefile', 'on');
    	sc_btn_display('uploadfile', 'off');
    }
    TSLink is a field showing a hyperlink to the uploaded file - if it's empty (i.e. no file has been uploaded for this record) then give the field some meaningful text and display the upload button and hide the delete button. If TSLink is not empty (i.e. a file has been uploaded for this record), then make the filename a hyperlink and hide the upload button, and show the delete button.

    NOTE: it's in onLoad in this instance as the form only shows a specific record - you cannot navigate records with it. If you are going to navigate through records then the above will need to be in onNavigate I would imagine.

    Comment


    • #3
      thanks

      Having two buttons had come to mind as a work around. It would be nice if it was a bit more dynamic.

      But thanks again, as it will probably be the way I have to go.

      Tony

      Comment


      • #4
        I remember to share a snippet in forums with a lib to do this search for it filtering by name.
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          If you can find it, it would be great.

          Tony

          Comment


          • #6
            Originally posted by fiscal View Post
            If you can find it, it would be great.

            Tony
            Prueba con esto http://www.scriptcase.net/forum/show...ll=1#post34502
            /Giuseppe

            Professional Scriptcase Services
            Some Customers opinions

            Comment

            Working...
            X