Announcement

Collapse
No announcement yet.

How to programmly change a button's caption?

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

  • How to programmly change a button's caption?

    as in the title, could change the button's caption in the PHP code?

  • #2
    Not directly. You can apply a javascript procedure in your html and use a sc_macro in php to call that.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Still have no idea, could you please show me how to do?

      Thank you very much.

      Comment


      • #4
        I'm not a javascript guru but you need to retrieve the object you need to change the title of. Then create a piece of javascript to put into the generated code, i.e. in the onapplicationinit. Then you need to call this javascript function by php with a sc macro: sc_ajax_javascript

        The next sample sends data to a javascript procedure, it's not doing what you want, but the idea should be clear:

        Code:
        echo '<script type="text/javascript">function disp_a(xfrm,xuri) { parent.document.getElementById("id-iframe-widget1").src="../form_sideline/form_sideline.php?glob_id=newcustomer&glob_shopid=generic"; } </script>';
        
        $javascript_function = 'disp_a'; // Javascript function name
        $javascript_parameters = array( // Javascript function parameters, add as many as needed
        '',
        '');
        
        
        // Call javascript function
        sc_ajax_javascript($javascript_function, $javascript_parameters);
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          oh Albert, I think he is lost more now lool

          I like it when you say I'm not java guru, see not me too, but at least you don't scare of the java code like I do, sometimes is definitely needed then I seek for help, but if I can avoid it, that is the best

          for example, did you try to make the button title that you want to change as a variable? then you can define this variable based on condition in some event...

          hmmm wait a minute, do you mean the "alt" "title" thing the light-yellow "caption" ? the hint? or the button label itself?

          Comment


          • #6
            Hello:

            I think that for us to give a better answear we need to know what kind of button, why and when you wanna change the caption.

            Regards

            Comment


            • #7
              Well a button is a button. It has some text in it and I assume that this caption needs to change depending on some data on the form. I solve these issues by setting buttons on and off but changing captions and / or behaviour would be preferabel. I never looked into that just because I want to avoid javascript.
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                Well yes:

                But how about he want to change the caption of the button "Add" to "Include" in all the project... then the easiest way wold be to modify the {language_variable} that's why I ask.

                Regards

                Comment


                • #9
                  Thank you very much.
                  I explain why I want to change the button's caption in the Grid's OnScriptInit event.

                  See the attachment, I make some buttons to do the Grid's filter, for the current user's click, it change to the current user's all item/todo item/done item, etc.

                  1.jpg

                  Then I want to show the items count in the button's caption, that's reasonable, you won't want your user only switch to the page to see how many records in the page. If can show in the button's text, that's obverse.

                  I tried to set the language var programmly, and it works to the page's header, in the code, I can change the page's header through a code like this:

                  {lang_tbl_zc_request} = {lang_tbl_zc_request} . " -- <font color=red><B>" . {lang_btn_itemtodo} . "</B></font>";

                  That's the picture's right top caption, we can easily change the page's header through the above code;

                  But we cannot change the button's caption through that, Like: {lang_btn_all} = {lang_btn_all} . " (100)";

                  It just cannot work, even put the code to the OnApplicationInit event.

                  It's a normal require to easily change a button's caption, is that right?

                  Comment


                  • #10
                    hi again, you mean something like blogs or social networks, to show My todo (3) and my done (20)

                    okay, same idea, create a variable in your onScriptInit and have it calculate that number for your items

                    then in your button text put something like "My todo [glob_mytodo]" this way you can add to your calculation code that if <=0 then show nothing, otherwise, show this number to user next to the button title, woudn't work this way? seems simple, not sure

                    Comment


                    • #11
                      WOOOOOO MikeSamaChanSempai good one bro.=D

                      Comment


                      • #12
                        Originally posted by kafecadm View Post
                        WOOOOOO MikeSamaChanSempai good one bro.=D
                        hi dude is that Chinese?

                        Comment


                        • #13
                          @MikeDE good idea, but have you try it?
                          I got like this:
                          2.jpg

                          Maybe the button's caption just ignore the global var.

                          Comment


                          • #14
                            @kafecadm, forget it, got what you mean, interesting approach though we don't use that around, Albert can be Sempai lool


                            @jerry oh means global will not work in buttons? WTF!! can you try java type button!? i don't have my sc dev with me to try, perhaps Sempai kafecadm can tell us how to use that in buttons

                            Comment

                            Working...
                            X