PDA

View Full Version : passing variables



HormonX
Aug 8th, 2002, 06:52 PM
well .. here i go again ...

is there a way to pass 2 variables from one form element. What am trying to do is this, in the pull down menu i have 2 distinct values i would like to pass. is there a way of passing the second variable some how ?

in the pull-down menu i have category and the subcategory

when you want to select something from the menu it looks somethig like this

category1 - subcategory1
category2 - subcategory2
category3 - subcategory3

is there any way so both of them are getting passed ?

please help

thanx HormonX

Spookster
Aug 8th, 2002, 07:34 PM
It would be easier if you just used two select boxes with one being the categories and the second being the subcategories. Like this:

http://javascriptkit.com/script/cut183.shtml

Then when submitted both values would be available to your php script.

HormonX
Aug 8th, 2002, 07:47 PM
you are right, it would be much easier ... i need the second menu (subcategory menu ) to be created dynamicaly. Am not that good with JavaScript that's why i haven't done that using JavaScript. It was much easier for me to pull 2 values from database and display them in one pull down menu.

The problem am having is that in not sure how to put PHP and Java Script together.

Do you know of a sample form just the one you showed me but done dynamicaly ?

thanx in advance

HormonX

Spookster
Aug 8th, 2002, 07:50 PM
You can pull the data from a db with that same concept. Use the first combo to select a category. Use an onchange event to trigger a form submit and query the database based on the selection and then regenerate the second combo box with the values that were pulled.

HormonX
Aug 8th, 2002, 08:09 PM
i got the concept on how to do it ... but being a novice .. am not sure where to begin and how to put things together, but thanx for the tip.

HormonX

Spookster
Aug 8th, 2002, 08:35 PM
To populate the second combo box using a db:

http://www.faqts.com/knowledge_base/view.phtml/aid/6123/fid/51

Just use the value obtained from the first combo box to use as the search criteria for the query on the database.