I really am not sure where to post this. I have a perl script with CGI, HTML and Javascript. The page contains a form with a lot of radio buttons, select boxes and text fields. It reads data for the radio buttons and select boxes from a mysql database.
There is one set of radio buttons (with two options) and 2 select boxes in particular who's data depends on the selected info in the others. Depending on what is currently selected among the radio buttons and select boxes, the other boxes should only display certain information. All of this comes from one table in the database. The data I am actually working with is very abstract and won't make sense to you, so I'll give a simple example to explain this further.
Let's say I have a table with the following columns:
Day - Meal - Food
Some sample information in this might be:
Saturday - Breakfast - Eggs
Saturday - Breakfast - Ham
Saturday - Lunch - Ham
Saturday - Lunch - Sandwich
Saturday - Lunch - Hot Dogs
Saturday - Dinner - Ham
Saturday - Dinner - Steak
Saturday - Dinner - Hamburgers
Saturday - Dinner - Hot Dogs
Sunday - Breakfast - Eggs
Sunday - Breakfast - Ham
Sunday - Breakfast - Omlette
Sunday - Lunch - Ham
Sunday - Lunch - Sandwich
Sunday - Lunch - Hamburgers
Sunday - Lunch - Hot Dogs
Sorry for the odd example.
So if someone clicks the Saturday radio button, the meal select box should contain 'Breakfast', 'Lunch', and 'Dinner'. However, if someone selects the Sunday radio button, the meal select box should contain 'Breakfast', 'Lunch'.
If someone selects Sunday and Lunch, the food select box should contain 'Ham', 'Sandwich', 'Hamburgers', 'Hot Dogs'.
If someone selects 'Steak' from the food list, the meal select box should only contain 'Dinner' and only the 'Saturday' radio button should be available.
I hope all of that made sense. I know how to add or remove information from select boxes and I know how to disable radio buttons using javascript. However, all of this information will need to come from the server side. Therefore I do not believe it is possible to take perl/cgi variables and use them in the javascript.
This leads me to believe that I need to refresh the page upon each selection. Then I can run an sql statement in perl/cgi to populate each select box based on the variables passed in the refresh. If this is what I need to do, I could use some direction on how to get started.
If you have any other suggestions or recommendations, please let me know, or if you think this post would be more suitable for a different board, please let me know.
There is one set of radio buttons (with two options) and 2 select boxes in particular who's data depends on the selected info in the others. Depending on what is currently selected among the radio buttons and select boxes, the other boxes should only display certain information. All of this comes from one table in the database. The data I am actually working with is very abstract and won't make sense to you, so I'll give a simple example to explain this further.
Let's say I have a table with the following columns:
Day - Meal - Food
Some sample information in this might be:
Saturday - Breakfast - Eggs
Saturday - Breakfast - Ham
Saturday - Lunch - Ham
Saturday - Lunch - Sandwich
Saturday - Lunch - Hot Dogs
Saturday - Dinner - Ham
Saturday - Dinner - Steak
Saturday - Dinner - Hamburgers
Saturday - Dinner - Hot Dogs
Sunday - Breakfast - Eggs
Sunday - Breakfast - Ham
Sunday - Breakfast - Omlette
Sunday - Lunch - Ham
Sunday - Lunch - Sandwich
Sunday - Lunch - Hamburgers
Sunday - Lunch - Hot Dogs
Sorry for the odd example.
So if someone clicks the Saturday radio button, the meal select box should contain 'Breakfast', 'Lunch', and 'Dinner'. However, if someone selects the Sunday radio button, the meal select box should contain 'Breakfast', 'Lunch'.
If someone selects Sunday and Lunch, the food select box should contain 'Ham', 'Sandwich', 'Hamburgers', 'Hot Dogs'.
If someone selects 'Steak' from the food list, the meal select box should only contain 'Dinner' and only the 'Saturday' radio button should be available.
I hope all of that made sense. I know how to add or remove information from select boxes and I know how to disable radio buttons using javascript. However, all of this information will need to come from the server side. Therefore I do not believe it is possible to take perl/cgi variables and use them in the javascript.
This leads me to believe that I need to refresh the page upon each selection. Then I can run an sql statement in perl/cgi to populate each select box based on the variables passed in the refresh. If this is what I need to do, I could use some direction on how to get started.
If you have any other suggestions or recommendations, please let me know, or if you think this post would be more suitable for a different board, please let me know.