option box selection results in text file display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brett Woodruff

    #1

    option box selection results in text file display

    ok, I'll explain this the best way I can... What I am trying to do is create an option box with several options, now by selecting option #1 will display Text File #1 in a textbox below the option box.... Option#2 displays Text File#2, and so on so forth, problem is I can figure out how to make the page load the text files.... any and all help will be greatly appreciated....

    thanks in advance
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    You can do this two ways.

    1. PHP alone

    Use the onchange() trigger on the option box to submit the page. Parse it with PHP and redisplay the page with the file included. use php's function file_get_conten ts() and echo it to a text box, html, or whatever the case maybe.

    2. AJAX
    Do the same thing but using javascript to get the file back. The easiest way to do this is to have a PHP function print a given file like this: print_file.php? filename=myfile 2.
    That page would just return the contents of the file, in this case, a file called myfile2.

    With jQuery it's easy to use the load() function to load the return of this file into an element of text area.



    Attempt either method and let us know where you get stuck.


    Dan

    Comment

    Working...