[SOLVED] automatic data into another field

I wondered if anyone can help me, i’m new to scriptcase and learning.

I have a two tables lets say table 1 and table 2.

Table 1 has two fields a description of a item and a weight of a item.

Table 2 I have created a drop down list from the first field in table 1 (description) working fine.

the problem i’m trying to solve is how in scripcase do I automatically put the weight of the item selected into a field in table 2?

I assume you have a form on table 2. The field which refers to the table 1 needs to be of type select. In the lookup you specify the key and description. On the form the description is shown, but in the database the keyvalue will be stored. So actually you don’t have to do a thing if you have already succeeded in creating the lookup.

my problem is this how do I get another field in the table to show a value from the select drop down? ie in table 2 the user selects the container type and when they do that i want the weight to be displayed in another field. table 1 contains the information for container type and weight, table 2 is going to be doing a calculation from the data my warehouse staff enter.

It’s probabely me, but I don’t quite understand what you want to do. If you want to fill other fields when a field changes you can define an ajax event on the changing field and in the event you can change the content of another field. Due to the fact that it’s done by ajax, your webform will not refresh, just the field. Is that what you want to do?

Yes this is what I want to do, please can you explain a little more.

thanks

create a container type onChange event
sc_lookup(dataset, “SELECT weight
FROM xxxxxx
WHERE xxxxxx.container_type=’{container_type}’”);

{weight}= {dataset[0][0]};

Ok im new to this, i sort of get the idea, but dont know where to put the fields in this code above.

table 1 is mdi_containers fields are container_disc and container_weight.

table 2 is named inbound_items fields are inbound_container (as a select drop down from table field container_disc) and inbound_container_weight.

this is what i have tried, but not working :frowning:

sc_lookup(dataset, “SELECT container_weight
FROM mdj_containers
WHERE mdj_containers.container_disc=’{inbound_container}’”);

{container_weight}= {dataset[0][0]};

sc_lookup(dataset, “SELECT container_weight
FROM mdj_containers
WHERE mdj_containers.container_disc=’{inbound_container} '”);

{inbound_container_weight}= {dataset[0][0]};

Thanks Frankotse, working perfectly.