This topic is locked

Populate Fields

11/3/2009 10:53:50 AM
PHPRunner General questions
T
Tempus_Erus author

Hi
I need to populate a a couple of fields based on a drop down box using PHP
Basically I need to produce a 'rate card':
I have a database called rates:
rate 1 - price1 - price2 - price3 - price4 -
rate 2 - price1 - price2 - price3 - price4 -
rate 3 - price1 - price2 - price3 - price4 -
Upon selecting a rate from a drop down box I would then like to populate the relevant fields with the appropriate price fields.
Any help is appreciated.
Ady

J
Jane 11/4/2009

Ady,
I recommend you to have a look at the 'How to setup dependent dropdown boxes on Edit/Add pages' tutorial here:

http://www.xlinesoft.com/phprunner/php-database.htm

T
Tempus_Erus author 11/4/2009



Ady,
I recommend you to have a look at the 'How to setup dependent dropdown boxes on Edit/Add pages' tutorial here:

http://www.xlinesoft.com/phprunner/php-database.htm


Thanks for that.
I have looked at this option, but it does not give what I need, or at least I don't quite understand its full capability.
I only require the 1 drop down box. The fields need to be populated accordingly.
In BASIC it would be an array DIM a(4,10). 4 lines of 10 if you like. I could then use a 'key' to represent a (1-4) and access the 10 'fields' accordingly.
Thanks.
Ady

J
Jane 11/5/2009

Ady,
this is how dependent dropdowns work. You choose rate in the first dropdown and second dropdown is filled with prices for selected rate.

Is it what you want to do?

T
Tempus_Erus author 11/5/2009



Ady,
this is how dependent dropdowns work. You choose rate in the first dropdown and second dropdown is filled with prices for selected rate.

Is it what you want to do?


Kind off. The 'first' drop down box will populate - say - 3 fields - with a cost. Not another drop down box.
Ady

Sergey Kornilov admin 11/6/2009

Ady,
dependent dropdown boxes don't have to look like dropdowns. You can make them look as normal edit boxes choosing option 'Edit box with AJAX popup'

K
khanate 11/16/2009

Ady,
Do you mean you want the dropdown list to look like this?
Rate Group A - $1.00 - $1.25 - $1.50 - $1.75

Rate Group B - $1.05 - $1.30 - $1.55 - $1.80

Rate Group C - $1.10 - $1.35 - $1.60 - $1.85
WHERE rate group name and all four prices are contained in each single rate group record?
To pseudo-code it, if you're using MySQL, you're wanting a lookup table in which each option is populated by

concat(ratename,' - ',price1,' - ',price2,' - ',price3,' - ',price4)
I first thought you meant that you would select the rate group and THEN select one of four prices, but if you are just wanting to see the four prices associated with the rate group, this type of code is what you would be looking for. Doing it would depend on the type of database you use, and you would specify the code in the lookup table section marked "Display Field", and then picking the Custom expression list item.
Does that do it?

T
Tempus_Erus author 11/16/2009



Ady,
Do you mean you want the dropdown list to look like this?
Rate Group A - $1.00 - $1.25 - $1.50 - $1.75

Rate Group B - $1.05 - $1.30 - $1.55 - $1.80

Rate Group C - $1.10 - $1.35 - $1.60 - $1.85
WHERE rate group name and all four prices are contained in each single rate group record?
To pseudo-code it, if you're using MySQL, you're wanting a lookup table in which each option is populated by

concat(ratename,' - ',price1,' - ',price2,' - ',price3,' - ',price4)
I first thought you meant that you would select the rate group and THEN select one of four prices, but if you are just wanting to see the four prices associated with the rate group, this type of code is what you would be looking for. Doing it would depend on the type of database you use, and you would specify the code in the lookup table section marked "Display Field", and then picking the Custom expression list item.
Does that do it?