php: populating 3 listboxes

Discussion in 'PHP' started by Richlife, Mar 30, 2008.

  1. Richlife

    Richlife New Member

    Joined:
    Mar 30, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    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!
     
  3. Mirey86

    Mirey86 New Member

    Joined:
    May 29, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    What do you mean by
    Code:
     ASP <---> Client
     PHP ---> Client
    
    @Richlife:

    How did your ASP implement this feature?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice