| View previous topic :: View next topic |
| Author |
Message |
mmathis
Joined: 25 Mar 2008 Posts: 8
|
Posted: Tue Mar 25, 2008 4:31 am Post subject: Dynamically creating form fields based on user selection |
|
|
I have a form with 3 fields. I want the third fields options to be based on what the user chose in the second form field. If the user chooses "income" in the second field then certain values appear as choices in the 3rd field. If the user chooses "expenses" in the second field, then different values appear as choices in the third field.
I've attached my code snippet. I'm not sure where to put the code for the third field. Should I put it in the display block after the $option_block2 select statement?
How would I reference the choice the user made in the second field? For some reason I seem to remember a way to do this using javascript but honestly dont recall. |
|
| Back to top |
|
 |
lostboy

Joined: 02 May 2004 Posts: 4958 Location: toronto, canada
|
|
| Back to top |
|
 |
mmathis
Joined: 25 Mar 2008 Posts: 8
|
Posted: Wed Mar 26, 2008 4:17 pm Post subject: |
|
|
This requires that you manually list each combination. I want to extract it from a mysql database. Ive found one but am having trouble configuring it for the second table.
The URL is http://www.phpclasses.org/browse/package/2289.html
It works with his simple tables. My first table is called types (ironically) has 2 fields, accountID and account_desc. I substituted type_id for accountID. My second table is called types_category and has a primary key made up of its only 2 fields, type and category. This is where I think my translation is in error. I changed type_id to type in the brand section (line 98 of the class). My third table is called cat_sub and has 3 fields, cat_subID whch is autoincrement, category and subcategory. Here I changed brand_id to category in the model section (line 108 of the class). His logic is that the brand_id is autoincrement so I'm not sure how he's matching them up.
Can you help me? |
|
| Back to top |
|
 |
lostboy

Joined: 02 May 2004 Posts: 4958 Location: toronto, canada
|
Posted: Thu Mar 27, 2008 3:15 am Post subject: |
|
|
No, it requires that each option choice becomes an array in the js, you can write out the values to the js array with php...thats what i did _________________ Lostboy
Cat, the other other white meat
Please read Posting Etiquette before posting
You can always try Google |
|
| Back to top |
|
 |
mmathis
Joined: 25 Mar 2008 Posts: 8
|
Posted: Thu Mar 27, 2008 4:15 am Post subject: Extract from db |
|
|
| what lines actually extract it from a database? I went through the code but didn't see this. |
|
| Back to top |
|
 |
lostboy

Joined: 02 May 2004 Posts: 4958 Location: toronto, canada
|
Posted: Thu Mar 27, 2008 5:19 am Post subject: |
|
|
It doesn't, you need to work that out _________________ Lostboy
Cat, the other other white meat
Please read Posting Etiquette before posting
You can always try Google |
|
| Back to top |
|
 |
|