I believe I do what you are attempting to do, in pure PHP using a switch
statement and variables. It works, (check www.northpointless.org to see it
in action) but keep in mind my site is in early developement, so the menu
options aren't quite fleshed out at this time.:

function menu ($pos, $sub = "none", $sub2 = "none") {
     global $PHP_SELF;
     global $sess_auth;
     switch($pos) {
          case main:
               print "<B><A HREF=$PHP_SELF>Home</A>";
               print "<BR><A
HREF=$PHP_SELF?sub=Comm&action=Comm>Community</A>";
               print "<BR><A HREF=$PHP_SELF?sub=JFF&action=JFF>After
Hours</A>";
               print "</B>";
               break;
          case secondary:
               switch($sub2) {
                case WOS:
                 $wos = "<FONT SIZE=-1><B>Add Slander</FONT>";
                 break;
       }
   switch($sub) {
        case Comm:
             print "<B>Message Boards";
             print "<BR>Mailing List";
             print "<BR>Job Listings";
             print "<BR>Member Directory";
             print "</B>";
             break;
        case JFF:
             print "<B><A
HREF=$PHP_SELF?action=wos&action_args=show&sub=JFF&sub2=WOS>Wall Of
Slander</B></A>";
             if ($wos) { print "<BR>$wos"; };
             break;
       }
       break;
     }
}
----- Original Message -----
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: "Nelson Goforth" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September 11, 2001 10:13 PM
Subject: [PHP] Re: Hierarchic menus using Javascript and PHP?


> See my response to Girish' post.
> You can't have JavaScript talking to PHP in real-time for
user-interaction.
> You either need to send your ENTIRE tree to JavaScript, or make the user
> choose on each page from a sub-menu...
>
> For that, you would just need to have JavaScript set the location to
> something involving the ID of the sub-category so PHP can then generate a
> new menu.
>
> --
> WARNING [EMAIL PROTECTED] address is an endangered species -- Use
> [EMAIL PROTECTED]
> Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
> Volunteer a little time: http://chatmusic.com/volunteer.htm
> ----- Original Message -----
> From: Nelson Goforth <[EMAIL PROTECTED]>
> Newsgroups: php.general
> To: <[EMAIL PROTECTED]>
> Sent: Monday, September 10, 2001 3:06 PM
> Subject: Hierarchic menus using Javascript and PHP?
>
>
> > On my site I have a page that takes input into a MySQL database
> > (though this isn't a db question).
> >
> > Each entry has a category and a subcategory entry, which should come
> > from predefined lists and are therefore instituted as pull-down
> > lists.  The category list is in a PHP array which feeds a SELECT
> > pull-down list.  The subcategory choices should depend upon what
> > category is selected.  In order to ease user input, I've used a
> > javascript function to cause the subcategory pulldown to depend upon
> > the category selection.  Thus if the category is Animals, the
> > subcategory SELECT would show "dog", "cat", "fish" - but if the
> > category were "Colors" the possible subcategories might be "Red",
> > "Green", "Yellow", "Puce".
> >
> > On the initial entry - a blank record - this all works fine.  But if
> > I go back in to modify a record I run into trouble, as I can't make
> > the page reflect the stored value of the subcategory within the
> > pull-down list (i.e. as the SELECTED item).
> >
> >
> > I use the following PHP code to display the $categories array - and
> > if there is a stored value ( $formValues["category"] ) it displays
> > that selection as "SELECTED" - which is exactly right.
> >
> >    printf("<TR><TD>Category </TD>");
> >    printf("<TD><SELECT NAME=category ONCHANGE=\"updateCats()\">\n");
> >    printf("<OPTION VALUE=0> === Select One === </OPTION>\n");
> >
> >    $i=0;
> >    while ($i < count($categories)) {
> >      printf("<OPTION VALUE=%s %s>%s</OPTION>\n",
> >        $categories[$i],
> >        $categories[$i] == $formValues["category"] ? "SELECTED" : "",
> >        $categories[$i]);
> >      $i++;
> >    }
> >
> >    printf("</SELECT></TD></TR>);
> >
> > But when it comes to the Sub-Category the list that feeds the SELECT
> > list is not in an array, but is coming from the JavaScript function
> > like:
> >
> >    if(subCategoryIndex == 1)  // Colors
> >      document.search.subcategory.options[1] = new Option('Red');
> >      document.search.subcategory.options[1].value = "red";
> >      document.search.subcategory.options[2] = new Option('Blue');
> >      document.search.subcategory.options[2].value = "blue";
> >      ...etc...
> >
> > I can't figure a way to make the 'Update' version of the page display
> > the value of the Sub-Category in a select list (so that the user CAN
> > update it).  I can certainly have the value display, but it no long
> > has the other possible members of the list, since it's not coming
> > from a display.
> >
> > I couldn't see a way to do this (updating one form element from
> > another) completely in PHP - else I would have.
> >
> > Does anyone have any ideas?
> >
> > Could I feed a PHP array FROM JavaScript?  If I could get the
> > subcategory selection list into an arry I think I could make this
> > work.
> >
> > Or possibly use another JavaScript script inside the PHP portion of
> > the page in order to force it to mark the appropriate item
> > "SELECTED"?  I tried this but couldn't make it work.
> >
> > Any help is appreciated - Thanks,
> > Nelson
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to