SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2002
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding Values From Database To Form

    I dunno why this got moved, because it has to do with PHP.

    I have Javascript for a form where the user get choices in fields based on what they chose in the previous field. In other words, I have the client side down.

    But how do I pull values from a database with PHP to fill in these arrays? I'm stumped. The first value in dynoMenu is what the user chooses, and the second value is the value used to represent it.

    //---==+0+==--- USER DEFINABLE SECTION ---==+0+==---

    mymenu = new dynoMenu(null,null);
    mymenu.sub[0] = new dynoMenu("Cathegory 1",null);
    mymenu.sub[0].sub[0] = new dynoMenu("Sub 1-1",null);
    mymenu.sub[0].sub[0].sub[0] = new dynoMenu("Sub 1-1-1","file111.html");
    mymenu.sub[0].sub[0].sub[1] = new dynoMenu("Sub 1-1-2","file112.html");
    mymenu.sub[0].sub[1] = new dynoMenu("Sub 1-2","file12x.html");
    mymenu.sub[0].sub[1].sub[0] = new dynoMenu("Sub 1-2-1","file121.html");
    mymenu.sub[0].sub[1].sub[1] = new dynoMenu("Sub 1-2-2","kaka.html");
    mymenu.sub[0].sub[2] = new dynoMenu("file 1-3-1","file131.html");

    mymenu.sub[1] = new dynoMenu("Cathegory 2",null);
    mymenu.sub[1].sub[0] = new dynoMenu("Sub 2-1",null);
    mymenu.sub[1].sub[0].sub[0] = new dynoMenu("Sub 2-1-1","file211.html");
    mymenu.sub[1].sub[0].sub[1] = new dynoMenu("Sub 2-1-2","file212.html");
    mymenu.sub[1].sub[1] = new dynoMenu("Sub 2-2",null);
    mymenu.sub[1].sub[1].sub[0] = new dynoMenu("Sub 2-2-1","file221.html");
    mymenu.sub[1].sub[1].sub[1] = new dynoMenu("Sub 2-2-2","file222.html");

    mymenu.sub[2] = new dynoMenu("Cathegory 3",null);
    mymenu.sub[2].sub[0] = new dynoMenu("Sub 3-1",null);
    mymenu.sub[2].sub[0].sub[0] = new dynoMenu("Sub 3-1-1","file311.html");
    mymenu.sub[2].sub[0].sub[1] = new dynoMenu("Sub 3-1-2","file312.html");
    mymenu.sub[2].sub[1] = new dynoMenu("Sub 3-2",null);
    mymenu.sub[2].sub[1].sub[0] = new dynoMenu("Sub 3-2-1","file321.html");
    mymenu.sub[2].sub[1].sub[1] = new dynoMenu("Sub 3-2-2","file322.html");

    mymenu.sub[3] = new dynoMenu("file 4-1-1","file411.html");
    //---==+0+==---END OF USER DEFINABLE SECTION ---==+0+==---

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2002
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump

  3. #3
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know how to do it without the Javascript (haven't spent any time to learn JS yet... /blush).

    Before you present your form to the user you run a DB query that pulls the current values out of the database, then when presenting your form you assign the values out of the database to the "value" of each of the form elements. This will prepopulate your form with the currently stored values, but let the user change them and re-POST.

    HTH.
    $slider = 'n00b';

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2002
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any PHP gets processed before the page hits the user's browser, so you can safely do something like this:
    PHP Code:
    mymenu.sub[0].sub[0].sub[0] = new dynoMenu('<?php echo $catName?>', '<?php echo $fileName?>');


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •