Re: [PHPLIB] Dynamic php/mysql queries with <selects> From: Davor Cengija (davor <email protected>)
Date: 11/27/99

On Fri, 26 Nov 1999, Robert D. Matthews wrote:

>Hi,
>I am trying to figure out how to make the contents of one <select> field
>on a form be populated based off of the value of another <select> field
>on the same form at runtime. The kicker is that they both need to pull
>information from a database. If I can figure out how to get a
>javascript function that will run a php3 script to query the database
>then it's relatively simple task to populate the selections. I can
>populate the first <select> field from the database as the form loads,
>the thing I can't figure out is how then populate the second <select>
>field as the value of the first changes. Anybody out there have any
>clues for me?

        If you're going to use JavaScript you assume your customers
        are using at least 'generation 3' browsers. In this case you
        can fetch all the possible data from the database while the
        page loads, save it under some JavaScript array variable and
        then display appropriate fields depending on the already
        selected field.

        You could check the eBay 'Choose the favourite category' page.
        
        I can send you the html page if you don't have the eBay
        account and don't want to open one. (or I can send it here,
        bz2 = 23K)

        Another way is the DHTML approach, where you assume your
        customers are using at least version 4 browsers.

        Use <IFRAME> and <DIV> tags with
        parent.<name>.document.location and <name>.load() functions to
        load another page from the server (can be php scripts, I'm
        doing it already). But, since those newly loaded pages are
        considered another documents, you could have big problems
        getting it to actually work.

        For more details, check http://www.dansteinman.com/dynduo/

        I'd suggest using the first, non-DHTML version.

        Another useful JavaScript links are:

        http://builder.com/Programming/Kahn/102198/index.html
        http://www.webreference.com

-- 
      v
Davor Cengija
davor <email protected>
===================================
"Please allow 30 days for delivery"

- PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in the body, not the subject, of your message.