Ted
|
| Posted: 01/20/2003, 10:07 AM |
|
Here is the problem. I have a dropdown list that is pulling information from a table in mysql. The table has 4 rows. What I am trying to do is when a person submits a form they have to make a selection from the dropdown list. I want the drop down list to dump a different row to a hidden text box. Hense the following example
I have a table with 4 cat
Package
Price
Tax
Delievery
These all have information
now what i want to do is have a drop down list that displays all the packages. This part a i figured out. What i want it to do is lets say a person picks package 1. Well package 1 is 14.99. I want it to put that number in a hidden field. Any ideas.
|
|
|
 |
feha
|
| Posted: 01/20/2003, 12:43 PM |
|
You have to use JavaScipt to acheive that wihtout updating thw whole page ...
(OnChange Event)
regards
feha
[www.vision.to]
|
|
|
 |
RonB
|
| Posted: 01/21/2003, 12:17 AM |
|
the code would look something like this:
( add the following to the input tag of the drop down)
onchange="document.all.hiddenfieldname.value=this.value"
RonB
|
|
|
 |
Ted
|
| Posted: 01/21/2003, 8:31 AM |
|
I have a page with say a form. In the form is a dropdown list. The drop down list is getting its information from the database. The database is structured like this.
Table= Plans
Id Plan Price Shipping
1 1x4 14.99 1.99
2 2x4 16.99 2.48
3 5x4 27.99 4.99
3 9x9 59.99 6.99
Now I have a form on the page with a drop down list. The dropdown list has the Plans listed in the list. The text in the list are the Plans. The information it puts in the database from the list is the price. Now I want to put the shipping in a hidden field.
|
|
|
 |
RonB
|
| Posted: 01/25/2003, 7:01 AM |
|
"Now I have a form on the page with a drop down list. The dropdown list has the Plans listed in the list. The text in the list are the Plans. The information it puts in the database from the list is the price. Now I want to put the shipping in a hidden field."
Table= Plans
Id Plan Price Shipping
1 1x4 14.99 1.99
2 2x4 16.99 2.48
3 5x4 27.99 4.99
3 9x9 59.99 6.99
I'm not sure I understand why you would want to do that. It looks like you are trying to store the same info twice. the shipping info is already available in your table example. If you use the dropdown in an order record you wouldn't need to store the shipping info since it can always be retrieved by linking from the created order to the table example you provided.
I'd setup the dropdown to show the plans and insert the plan id into your order table. the table could look something like this (just the order bit not the client info)
table orders
ord_id plan_id
1 1
if you now create a grid to show the order in detail you take the plan table and the order table and join them on plan id
you would get a grid looking like this:
orders
order_id 1
Plan 1x4
price 14.99
shipping 1.99
The only reason to store the same info twice is if you use the same database to do your accounting. If you create an invoice from the database and this is then used to proces the order into professional accounting software there is no need to store the info twice. If you do need the web database to do the accounting you should store price and shipping in the order table otherwise my example would change the total price of orders already processed.
But even if you do need to store the same info twice the combination of plan and price in a dropdown isn't a good idea. Let's say you get two plans with the same price...how would you know wich plan was ordered? combine plan with id and insert the id in the order table. do an AfterInsert event to insert the corresponding price,and shipping info in the order table.
Ron
|
|
|
 |