PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
HTMLQuickform Displaying new fields

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML
View previous topic :: View next topic  
Author Message
Legend



Joined: 24 Feb 2008
Posts: 10

PostPosted: Sun Feb 24, 2008 8:02 pm    Post subject: HTMLQuickform Displaying new fields Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 24, 2008 8:58 pm    Post subject: Re: HTMLQuickform Displaying new fields Reply with quote

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
View user's profile Send private message
Legend



Joined: 24 Feb 2008
Posts: 10

PostPosted: Sun Feb 24, 2008 9:06 pm    Post subject: Re: HTMLQuickform Displaying new fields Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 24, 2008 9:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
Legend



Joined: 24 Feb 2008
Posts: 10

PostPosted: Sun Feb 24, 2008 9:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Feb 24, 2008 9:15 pm    Post subject: Reply with quote

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. Wink But you'll get an answer in the other thread.
Back to top
View user's profile Send private message
Legend



Joined: 24 Feb 2008
Posts: 10

PostPosted: Sun Feb 24, 2008 9:16 pm    Post subject: Reply with quote

Oh ok Smile Thanks a lot for your time...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software