Re: [PHP] related products, how to's best practices

From: Ajai Khattri (ajai_at_bway.net)
Date: 12/04/03


Date: Thu, 4 Dec 2003 12:29:56 -0500
To: php-general@lists.php.net

On Thu, Dec 04, 2003 at 03:43:53PM +0000, Jon Bennett wrote:

> Would I be right in thinking that php alone can't change the content of
> a dropdown once the browser has loaded the file without a page refresh
> ??? In which case I need to source out some javascript, anyone got
> anything that might help me (code, tute, urls etc) as I'm not having
> much luck with google ??

I have done this in JavaScript - but I dont have any code handy.

Basically you will need to pre-generate a series of JavaScript arrays for each
category of product at the top of the web page. Then you have a JavaScript
event handler in the category pulldown that changes the product pulldown to a
different array whenever the category changes (use something like onClick or
onChange or a similar relevant event).

Works pretty well - I once worked on a project which pulled data from Access
via ODBC (I was coding in ASP - bleh! Never again... ;-) and generated the web
page with the arrays and JavaScript functions at the top to handle the
switching of the pulldowns.

-- 
Aj.
Sys. Admin / Developer


Relevant Pages

  • Re: Using AJAX/JSON and performance issues with eval()
    ... evalevaluates its string argument as an ECMAScript ... JS arrays are implemented as objects, ... multiple HTML tables automatically in the background) and really want it ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)
  • Re: Math.random
    ... But, as the seed is exposed, randoms can be ... Using just ordinary JavaScript ... arithmetic has to be done with arrays of digits. ... as one might reasonably have hoped, and also is a security leak. ...
    (comp.lang.javascript)
  • Re: JavaScript associative arrays not ordered?
    ... "In JavaScript an object is a mapping from property names ... If wikipedia wish to define an "associative array" as "a mapping from ... So much of what associative arrays ... Inevitably false expectations about javascript will not ...
    (comp.lang.javascript)
  • Object instead of array? Any problems?
    ... Javascript isn't my specialty, ... TONS of arrays, and I'm using vbscript to actually build them into the ... lol - it's a mess. ...
    (comp.lang.javascript)
  • Re: Dependent dropdowns
    ... > Looking for a simple javascript solution to this and it's annoying me ... of OPTION tags from arbitrary lists of data available on the server than to ... build JS arrays, and the demands on the client are smaller. ...
    (microsoft.public.scripting.jscript)