Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   php: populating 3 listboxes (http://www.go4expert.com/forums/php-populating-3-listboxes-t9653/)

Richlife 30Mar2008 19:28

php: populating 3 listboxes
 
I was converting old asp files to php.

But I'm stuck at this point.

I'm looking for a triple combo listboxes where one has "book" the other "chapter" and the third "verse". The book is populated by a database table. Once book is selected then chapter is populated and then verse.

Any tutorial related to this?

pradeep 30Mar2008 21:04

Re: php: populating 3 listboxes
 
Seems like we don't have such an article here yet. You can either use AJAX, or submit the form on combo box change to achieve your objective. Try it out....and do let us know if you are stuck!

Mirey86 29May2008 12:53

Re: php: populating 3 listboxes
 
PHP isn't exactly capable of what you are trying to do.

ASP <---> Client
PHP ---> Client

You could get around this by creating JavaScript arrays and looping through them when the user clicks a book and populate the listbox that way.

Eg.
User loads page... Every book is loaded, alongside the book's chapters and verses for every chapter, they are all stored in JavaScript array... The user clicks a book, in the onchange event for the listbox, use JavaScript to loop through the appropriate array using the foreach() method... Then add nodes to the next listbox...

The above method is inefficient but it should work.

If that doesn't take your fancy, perhaps frames? and using the JavaScript onchange event to modify the url of the next frame. The url may contain $_GET data (Eg. You load the url: mysite.com/getchapters.php?bookid=34) then you can use PHP to fetch all the chapters in the book.

I hope I helped you.

Mirey :D

pradeep 29May2008 13:34

Re: php: populating 3 listboxes
 
Quote:

Originally Posted by Mirey86
PHP isn't exactly capable of what you are trying to do.

ASP <---> Client
PHP ---> Client

You could get around this by creating JavaScript arrays and looping through them when the user clicks a book and populate the listbox that way.

Eg.
User loads page... Every book is loaded, alongside the book's chapters and verses for every chapter, they are all stored in JavaScript array... The user clicks a book, in the onchange event for the listbox, use JavaScript to loop through the appropriate array using the foreach() method... Then add nodes to the next listbox...

The above method is inefficient but it should work.

If that doesn't take your fancy, perhaps frames? and using the JavaScript onchange event to modify the url of the next frame. The url may contain $_GET data (Eg. You load the url: mysite.com/getchapters.php?bookid=34) then you can use PHP to fetch all the chapters in the book.

I hope I helped you.

Mirey :D

What do you mean by
Code:

ASP <---> Client
 PHP ---> Client

@Richlife:

How did your ASP implement this feature?


All times are GMT +5.5. The time now is 22:47.