Announcement

Collapse
No announcement yet.

Update button with code ?

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

  • Update button with code ?

    Can I invoke the update button with code in a form?
    So I donot want to press the update button, but want to update the data in a form by code in an event.
    Regards Bert

  • #2
    Yes you can, but in the php code you need to manually supply the sql statement. You can remove all buttons from the toolbar and add a custom button to do so.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Hi Albert,

      I will give it a try and report the results.

      Bert

      Comment


      • #4
        Thanks Albert,

        Yes it works fine. Simply with an UPDATE SQL.

        I completed this with a refresh of the form with code:

        In the php script I wrote: sc_ajax_javascript('refresh');
        which calls a java-method with this name in my form with only one-line:

        location.reload()

        This does the same a your refresh button in the browser.

        Great stuff this Scriptcase...I love it.

        Bert

        Comment


        • #5
          Sorry small mistake.
          The refresh refreshes the complete form and that results in come back on record one everytime.
          That's not what I want.
          Continue with finding out.
          Regards Bert

          Comment


          • #6
            Yes I found it.

            Sometimes the solution is more easy then you think.

            When you touch the button "update" in a form than you can see some java-code in the left-bottom corner of your browser (firefox).
            Take this code in a java script, that's it. You can do it with every button.
            In my case:
            nm_atualiza('alterar');

            Use sc_ajax_javascript('save') in which 'save' is the name of the javascript with the nm_atualiza('alterar');


            Great stuff Scriptcase.

            Kind Regards, Bert
            Last edited by ctmservice; 02-17-2014, 04:56 PM.

            Comment


            • #7
              Great to hear that you succeeded. This is a great solution to be remembered, at least for me.
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                i try this solution but don't work for me.

                Use sc_ajax_javascript('save') in which 'save' is the name of the javascript with the nm_atualiza('alterar');

                any solution?

                Comment


                • #9
                  You have to make a js function called 'save' for ex with that code in it
                  Code:
                  nm_atualiza('alterar');

                  Comment


                  • #10
                    In a javascript method (in programming) with the name "save" I used:

                    nm_atualiza('alterar');
                    return false;

                    In PHP I used:
                    sc_ajax_javascript ('save');

                    Look for the scope of "the sc_ajax_javascript" in the tutorial.
                    Only to be used in a form not in a grid. I did not try it in a button...

                    Hope this will help..
                    In my app it's working fine. And as I said you can do it with all the sc buttons.

                    Comment


                    • #11
                      I created a javascript method with name "save" I used:

                      nm_atualiza('alterar');
                      return false;

                      In PHP BUTTON I used:
                      sc_ajax_javascript ('save');

                      but dont work why?

                      Comment


                      • #12
                        Originally posted by marcov View Post
                        I created a javascript method with name "save" I used:

                        nm_atualiza('alterar');
                        return false;

                        In PHP BUTTON I used:
                        sc_ajax_javascript ('save');

                        but dont work why?
                        Hello... don't use a php button, use a JavaScript button!!! i've done it

                        Comment


                        • #13
                          Hello,

                          In SC8 I have kind of same problem. There is a form, there are numeric fields: field1, field2. When user changes the value of field 1, the field1's OnChange event calculate a number and set it to field2.

                          The problem is:
                          when the focus is in field1 and the user changes the value of it, and instead of leaving the field1's focus, he clicks the Update button, the onChange event of field1 hits and it calculates the field2 successfully, but the form update event doesn't hit. So he click back button and the form doesn't update nor field1 and field2's values. If I would like to be sure it saves the data, I needs to click the Update button at leastTWICE to be sure, the datas are save.

                          The JavaScript method above doesn't work only 1 time, I mean I can call this javascript method only once, after the form open, because when I call 2nd. times Firebug sais:
                          TypeError: node is undefined
                          data.parent = node.parentNode;

                          Can someone help me?

                          Comment

                          Working...
                          X