[SOLVED] Showing and hiding fields

Dear all,

I have to manage some fields within an editable grid.
The form is about payments and I have to manage Cash in and Cash out entries and all connected fields.

If I choose that payment is a Cash in all the other field connected to Cash out info have to be hide.
I’m trying to use Ajax Events On Blur and On Change but I have some problems .
Is there a “right” way to manage this topic.

amount_in and amount_out are the two fields.
I have to check that if you leave blank/empty or = 0 the first one means that you want to insert a amount_out and so I will hide other columns connected to amount_in.
If I insert an amount on amount_in it’s easier.
The problem I have is when you are in amount_out and after a while you go to delete its content. In that case I have no control. Need I a refresh ? How can I manage all cases ? Need I to use on blur and on change too ?

Bye
Giovannino

I’ve started some test…

amount_in_onBlur
//Control if a value is in or out
if ({amount_in}==’’ or {amount_in}==0)
{ sc_field_readonly({amount_in}, ‘on’);
sc_field_readonly({amount_out}, ‘off’);
{amount_in}="";
sc_set_focus(‘amount_out’);
}

else { sc_field_readonly({amount_in}, ‘off’);
{amount_out}= “”;
sc_field_readonly({amount_out}, ‘on’);
sc_set_focus(‘currency’);}

if (({amount_out}==’’ or {amount_out}==0))
{ sc_field_readonly({amount_in}, ‘off’);
{amount_out}= “”;
sc_field_readonly({amount_out}, ‘off’);
}

// and ({amount_in}==’’ or {amount_in}==0)

amount.png

[SOLVED] Showing and hiding fields

After many test the solution has come (probably it could be done in a easier way… :wink: ) but it works;

amount_in_onBlur

if ({amount_in}==’’ or {amount_in}==0)
{ sc_field_readonly({amount_in}, ‘on’);
sc_field_readonly({amount_out}, ‘off’);
{amount_in}="";
sc_set_focus(‘amount_out’);
}

else { sc_field_readonly({amount_in}, ‘off’);
{amount_out}= “”;
sc_field_readonly({amount_out}, ‘on’);
sc_set_focus(‘currency’);
}

if (({amount_out}==’’ or {amount_out}==0))
{ sc_field_readonly({amount_in}, ‘off’);
{amount_out}= “”;
sc_field_readonly({amount_out}, ‘off’);
}

amount_out_onBlur

if ({amount_out}!=’’ and {amount_in}!=’’)
{
{amount_in}=’’;
sc_set_focus(‘currency’);
}
if ({amount_out}==’’ and {amount_in}==0)
{
{amount_out}=‘0’;
sc_set_focus(‘amount_in’);
}

Bye
Giovannino