#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    98
    Rep Power
    11

    Can Javascript run a PHP file and return the vaule in a dropdown menu??


    Can someone please answer this for me??
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,186
    Rep Power
    2265
    No.

    Javascript runs client-side, in the browser, on the client's computer.

    PHP runs server side, and outputs HTML &/or javascript to the browser.

    Javascript cannot interact directly w/ a file system - either server side or client side (for security reasons).

    The best you could do would be to parse through a PHP file and output it via HTML to the browser w/ in a drop menu.
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    98
    Rep Power
    11
    so how do i get started in that direction...i'm a newbie....


    thanks
  6. #4
  7. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,186
    Rep Power
    2265
    Originally posted by littlab
    so how do i get started in that direction...i'm a newbie....


    thanks
    Start reading and working with examples of the functions in PHP and Javascript you'll need to build your code. Once you have a good idea of how the underlying programming concepts work together, then begin your project.

    Specifically, you'll need the fopen() function out of the filesystem functions to get the PHP file and parse it; you'll need either strstr() from the strings functions, or possibly various preg...() functions from the PCRE functions to find the data for your drop menu...

    Additionally, you'll need various javascript techniques to create a menu which auto-submits when an option is selected... I don't have links available immediately for those, so you'll have to do some research on it. Javscript.com is a good place to start.

    If you hit a brick wall while learning this stuff or coding your app, let us know, we're here to help you.
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
  8. #5
  9. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,938
    Rep Power
    4033
    You can do something like this, however it's not a very pretty solution. Since javascript can't call up URL's and get their content, what you have to do is use a hidden frame or iframe and load the url in that, then use javascript to get the source when it's loaded.

    I have made an example of this before which you can see at
    http://kicken.mine.nu:8008/extras/zorek.html
    and the php code at
    http://kicken.mine.nu:8008/extras/zorek_loadmenu.phps
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    98
    Rep Power
    11
    I'm gonna need a little more help than that after reading through those pages. I'm going to read over them again to see if it can sink in.

IMN logo majestic logo threadwatch logo seochat tools logo