Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variable from one listmenu to another

Status
Not open for further replies.

mysteryminds

IS-IT--Management
Aug 5, 2005
9
MU
Assuming I have 3 list boxes
Example :
Cars----------Models--------------type
---------------------------------------
All the fields will be dynamically from single table
Cars field has
NISSAN
TOYOTA
SUBARU
HONDA
MITSUBISHI
MAZDA
PROTON
CIEOLO
SCODA

MODELS fields will have list
--------
CIVIC
ACCORD
CRV
TRUCK
V5
CARRYBOY

TYPE fields
1200CC
1500CC
1800CC
2000CC
2500CC


Honda---------ACCORD-------------2000CC

Assuming User selects HONDA from first list menu (CARS_
The (MODELS)listmenu will display all the models related to HONDA from database.
type will display all the types related to the selection made in MODELS list menu.

I'm able to retreive all the fields from the database but I'm not able to pass the values from from listmenu to second list menu and to third from second.


 
I think in is pointless to store all these in a single table that way.
This would mean that field values in one row of your have something common, but they do not!

You would probably want to link 'types' (I assume this is the engine volume with my small knowledge of cars) with car models, becouse each car model has its own engine volume, so you will actually need two tables:
'cars', whitch stores data about whitch producer makes whitch cars
and 'volumes' whitch stores data about whitch car model has how much engine volume.
Example:

'cars':
--carname-- --relmodels--
HONDA CIVIC,ACCORD

'volumes'
--model-- --volume--
CIVIC 2000CC
ACCORD 3000CC

this would be a good database model, the example tells you HONDA makes cars CIVIC and ACCORD, and that CIVIC has 2000CC engine and ACCORD has 3000CC engine.

You can get seperate car models from the --relmodels-- field using the split() function. Than you make a query for each car model to get engine data.
 
ambroz
Thanks for your suggestion. But the actual db is not that at all.
OUR db consists of Tsunami victims where they gave us single file excel file which organisation is working on.

We wanted to use that single database of the victims which consists mainly of Surname, Forename, Address1, Town

So we would like to create IDiot proof search for layman
All they would do is select from dropdown list which gives the DISTINCT of SURNAMES and second LISTBOX would give all the fornames of the person whose surnames are bla bla bla so that we can trace out the people

 
That's the other thing. You should tell me this, not make some other stuff out of it. So, every row in your DB has data of one victim. This is correct.
So in the first box you would just list all the surnames like:
"select Surname from victims"
Than you will have to select names spacific for one surname.

You can query all fornames for all surnames and put in in a javascript, but I don't like this case becouse you make a query of all data in the table for just one client.

Or you can maka a javascript to submit a form when a surname is clicked in the list (I like that one much more) and a parameter containing the surname is sent back to the server that also lists all the forenames for that surname:
"select Forename from victims where Surname='Johnson'
 
Well thats right ambroz
we are using all that the first field might also be anything thing (e.g he can select surname, forename, add1, town) according to the selection the second listmenu will be built.

(e.g first list box will be like select Distinct surname (or firstname, forename, add1, town) from table )

assuming user selected forename in the first list menu the second listbox will contain (select forename from table where surname='selected surname';

Well all I'm looking for is how can i pass the value from one list menu to other listmenu without any submit. I surely do know that Onfocus() is the option, but don't know how to do it.
 
What you're looking to do can be done with Javascript, not PHP. Ask your question there.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top