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

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.

Hi Albert,

I will give it a try and report the results.

Bert

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

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

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

Great to hear that you succeeded. This is a great solution to be remembered, at least for me.

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?

You have to make a js function called ‘save’ for ex with that code in it

nm_atualiza('alterar');

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.

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?

[QUOTE=marcov;21603]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?[/QUOTE]

Hello… don’t use a php button, use a JavaScript button!!! i’ve done it

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?