This topic is locked

How to display image based on Lookup Table

4/10/2009 2:29:18 PM
PHPRunner General questions
L
Lisa2006 author

Hi Forum,
I have 2 tables as follows:
Table: vehicle

Field: vehicle - varchar(100)
Table: suppliers

Fields: vehicle_name - varchar(100) & vehicle_image - varchar(100)
Via Visual Editor 'suppliers table', add page, vehicle_name field, i have set up a lookup table to table vehicle, field vehicle
I have populated the vehicle table with 3 static entries: bike, car & van
From suppliers_add.php i can select from the drop down field either bike, car or Van .... this bit work fine!!!
Here's where i need some help

When the user goes to the suppliers_add.php page and selects "car", i need a way to display a preset image car.gif in the vehicle_image field. Likewise if the user selects "bike" then the image motorbike.gif will be displayed.
Your help and support would be much appreciated.
Lisa

J
Jane 4/13/2009

Hi,
to fill vehicle_image field with correct value use Before record added/Before record updated events on theEvents tab.

Here is just a sample:

if ($values["vehicle_name"]=="bike")

$values["vehicle_image"]="motorbike.gif";


Unfortunately there is no easy way to show selected image on the fly.

L
Lisa2006 author 4/14/2009

Hi Jane,
Can this accomplished using javascript?
If so, can you please provide a sample script.
Thank you in advance
Lisa

J
Jane 4/14/2009

Unfortunately there is no easy way to do it.