sc_redir - a... return ticket... I've a confirmation form with yes/no fields.

Dear all,

I’using sc_redir from FORM(A) form_orders to open a confirmation form FORM(B) form_yes_no_order . The output of FORM(B) is glo var like [yes_no] that could be 1 or 2.

The sc_redir of FORMA(A) is within the event OnAfterUpdate:

sc_redir(form_yes_no_order.php);

if ([yes_no] == 1 )
{ echo " Do something if yes " . [yes_no]; }
elseif ([yes_no] == 2)
{ echo " Do something if no " . [yes_no]; }
else
{ echo " Something else " . [yes_no]; }

The same in FORM(B) under OnAfterUpdate:
[yes_no]={yes_no};
sc_redir(form_orders.php);

My question is : when I come back from confirmation form FORM(B) to FORM(A) what happens ?
Is it correct to make the test of answer under OnAfterUpdate as above or have I to put the test under some other event ??
Shortly when you call another form which is the event that is done first ?

if ([yes_no] == 1 )
{ echo " Do something if yes " . [yes_no]; }
elseif ([yes_no] == 2)
{ echo " Do something if no " . [yes_no]; }
else
{ echo " Something else " . [yes_no];

Thanks

In the onscriptinit I would have something like:

if ([yes_no]=’’ )
{
[glob_return]=‘formorders.php’;
sc_redir(form_yes_no_order);
}

// here your code

I advise you to set the global through the parameterlist. I’ve had a lot of samples where the global was not put through. So in form_yes_no_order something like

sc_redir([glob_return],yes_no={myfield});

Hi Aducom,

my problem is now to manage the glo_var [yes_no] becouse
I have to reset it to 0 in order don’t make the if statement down here. If I write [yes_no]=0 on FORM(A) then when I come back from confirmation form(B) it reset to 0 again everytime [yes_no] and so I can’t make the following steps.
If I leave [yes_no] as it is without resetting it found available last time of glo var and due to that FORM(A) makes itself the “if” lines below becouse it has in memory the variable value 1 or 2 .

if ([yes_no] == 1 )
{ echo " Do something if yes " . [yes_no]; }
elseif ([yes_no] == 2)
{ echo " Do something if no " . [yes_no]; }
else
{ echo " Something else " . [yes_no]; }

Perhaps something like this?

if ([yes_no] == 1 )
{ [yes_no]=0;
echo " Do something if yes " . [yes_no]; }
elseif ([yes_no] == 2)
{ [yes_no]=0;
echo " Do something if no " . [yes_no]; }
else
{[yes_no]=0;
echo " Something else " . [yes_no]; }

Ok. I will try.
So the best thing to do is to put the reset to the end of the code in order to be sure that next time you’ll use it the glo_var start from 0 value and do not make the If=1 and if=2 steps.
Bye

Hi,
I’ve a strange behavior. It works in some way but I loose the data from grid after the sc_redir.

  1. In a editable grid I edit a field or more that one changing the present value into a new one. Then I’ve insert onValidadesuccess the sc_redir to confirmation form.
  2. The confirmation form opens and then I choose YES . Yes means that I want to update also another table .
  3. When I come back from the confirmation form to the editable grid the application makes if ([yes_no] == 1 ) and update the other table using data stored before on glo variables. Data in the other table have been modified as expected and everything is correct.
  4. At this point the editable grid looses the edited new data (changed before) showing me the original values again (the same as I would open the grid for the first time).

I’ve tryed to put the sc_redir also under AfterUpdate but the problem remains .
Wich could be the mistake ?

See video : http://www.youtube.com/watch?v=myyXTM6xj94

If you do a sc_redir you need to make a manual commit regarding your transaction using macro: sc_commit_trans(); I always do this before the redir, don’t know if it will work after return…

WOWWWWWWWOWOWOW !!! Thanks so much !