| View previous topic :: View next topic |
| Author |
Message |
Legend
Joined: 24 Feb 2008 Posts: 10
|
Posted: Sun Feb 24, 2008 8:02 pm Post subject: HTMLQuickform Displaying new fields |
|
|
I tried for a long time but I don't know how to make it display new fields when a user selects a particular option. The general flow of the program is something like:
| Quote: |
Create a new HTMLQuickform object
Add elements to it
if(form->validate())
---Do the form processing stuff
else
---form->display()
|
Can someone please help me out?
Example: Which country do you belong to? is a drop down box option and when the user clicks on it, I should be able to do a SQL query to get some other question based on the selection and display it.
Also, while using a hierselect element, how do I specify an id for the element? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sun Feb 24, 2008 8:58 pm Post subject: Re: HTMLQuickform Displaying new fields |
|
|
| Legend wrote: | | Example: Which country do you belong to? is a drop down box option and when the user clicks on it, I should be able to do a SQL query to get some other question based on the selection and display it. |
How do you want to do this? On the client side? That's a little bit tricky with QF, and needs some work. If you want to do it on the server side, you would just check the submitted value of the box: If there is a submitted value, you would send your SQL query, and add another element(s) to your form.
| Legend wrote: | | Also, while using a hierselect element, how do I specify an id for the element? |
$element->setAtttribute('id', 'whateveryouridshouldbe');
with $element being the hierselect element that you have created |
|
| Back to top |
|
 |
Legend
Joined: 24 Feb 2008 Posts: 10
|
Posted: Sun Feb 24, 2008 9:06 pm Post subject: Re: HTMLQuickform Displaying new fields |
|
|
| mark wrote: | | If there is a submitted value, you would send your SQL query, and add another element(s) to your form. |
Yes... This is what I'm not understanding. Where do I add the new element? Suppose that I have the following code:
| Quote: | Create a new HTMLQuickform object
Add elements to it
if(form->validate())
---Do the form processing stuff
---if(element with the id has been submitted)
------add another element to form
------then break out of the if condition? or do I have to do something else?
else
---form->display() |
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sun Feb 24, 2008 9:13 pm Post subject: |
|
|
You should add the items before the validate() call, i.e. right after you add the other items.
If this question is related to your other thread, we stop here and stay in the other thread to avoid confusion. |
|
| Back to top |
|
 |
Legend
Joined: 24 Feb 2008 Posts: 10
|
Posted: Sun Feb 24, 2008 9:14 pm Post subject: |
|
|
| Sure... I'll bring this up in the other thread. Just thought its better to have a non Ajaxian thread... You can delete this thread if you want. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sun Feb 24, 2008 9:15 pm Post subject: |
|
|
| Legend wrote: | | Sure... I'll bring this up in the other thread. Just thought its better to have a non Ajaxian thread... You can delete this thread if you want. |
I can't delete it. But you'll get an answer in the other thread. |
|
| Back to top |
|
 |
Legend
Joined: 24 Feb 2008 Posts: 10
|
Posted: Sun Feb 24, 2008 9:16 pm Post subject: |
|
|
Oh ok Thanks a lot for your time... |
|
| Back to top |
|
 |
|