How update a form field value based on the value of other field

Dear all,

I’ve a form with a field that is the ITEM_ID i.e. “artico_xid_id” connected to a grid with a capture link .
On the same form I have other fields (display only) that are part of this master data item (same table of capture link).
i.e. “inventario” that is the SERIAL NUMBER of ITEM_ID.

If I go to insert/update the field ITEM_ID I’m not able to see the MATERIAL_TYPE refreshed becouse I’ve still not inserted/updated the record. Only if I save and then go back my additional data appears.

I’ve tried to add an Ajax Event (OnChange) on ITEM_ID and I’ve inserted this code:

sc_lookup(serial_number,“SELECT codice FROM warehouse_artico WHERE id = {artico_xid_id}”);
{inventario} = {serial_number[0][0]};

How can now see the value of “inventario” field updated on my form.
Have I to add some code ?

Many thanks
Giovannino

http://img135.imageshack.us/img135/280/artico.png

Re: How update a form field value based on the value of other field

instead of

please try

sc_lookup(serial_number,“SELECT codice FROM warehouse_artico WHERE id = {artico_xid_id}”);
{inventario} = {serial_number}[0][0];

I think thats it

Re: How update a form field value based on the value of other field

Many thanks !
My new step forward is this one. I looked up three values and I got them on echos messages.
Within on change I wrote this code:

sc_lookup(serial_number,“SELECT codice FROM warehouse_artico WHERE id = {artico_xid_id}”);
{inventario} = {serial_number}[0][0];
echo "Inventario ". {inventario};

sc_lookup(material_type,“SELECT tipoma_xid_id FROM warehouse_artico WHERE id = {artico_xid_id}”);
{artico_tma} = {material_type}[0][0];

echo " Tipo articolo ". {artico_tma};

sc_lookup(mat_type_desc,“SELECT warehouse_tma.descri FROM warehouse_tma, warehouse_artico WHERE warehouse_tma.id = warehouse_artico.tipoma_xid_id and warehouse_artico.id = {artico_xid_id}”);
{descri_tma} = {mat_type_desc}[0][0];

echo " Descrizione ". {descri_tma};

Now I have all correct data and with echo I can see them . Why nothing appears on field forms ?
Have I to make a kind of assign command to update the form’s fields contents ?
Bye
Giovannino

http://img843.imageshack.us/img843/854/appears.png

Re: How update a form field value based on the value of other field

Hi Giovannino, did you find a solution for this?
I’m having the same problem.
Manual says this is the right procedure, but I don’t get it.

Re: How update a form field value based on the value of other field

I am having this same problem – how to transfer a value from a select pull down menu onto the main table form. How do you force the form to be redisplayed with the updated value?

Re: How update a form field value based on the value of other field

Hi all.
Is this case solved?

Re: How update a form field value based on the value of other field

You cannot simply change a variable and expect the new value to update itself in a form. SC creates a HTML form that display the data, you have to refresh this form/field by either using an AJAX call for that field, or reloading the form after the variables have been updated. AJAX would be the best approach.

http://www.scriptcase.net/systems/v5/exemplos_en_us/grid31/grid31.php

Regards,
Scott.

Re: How update a form field value based on the value of other field

Think of it this way … SC creates a “picture” of the data and displays it to the screen. If you make a change to the data, you have to take a new picture to see the change on the form.

AJAX calls allow you to make changes to the picture.

Regards,
Scott.