How do I open a flatfile based on a drop-down selection?

Below I have a drop down list with items referring to data-files (flatfile).  Each flatfile contain the records that guest selected when signing the guestbook.

Given the following drop-down option

                <select size="1" name="vcat" >

      <!--[OPTIONS]-->
      <Option value="gb_Dis.dat">Disabled Access</option>
                <Option value="gb_Loc.dat">Local Information</option>
                <Option value="gb_Wea.dat">Weather</option>
                <Option value="gb_Cur.dat">Currency</option>
                <Option value="gb_Apa.dat">Apartments</option>
                <Option value="gb_Res.dat">Restaurants</option>
                <Option value="gb_Com.dat">Complex</option>
                <Option value="gb_Lei.dat">Leisure &amp; Entertainment</option>
                <Option value="gb_Act.dat">Activities for Kids</option>

              </select></td></tr>

how do I get it that the appropiate file loads and display the contents (the loading of the file is important! - variable=$datafile).  I gather an onchange event handler is required - but I just don't know how! I want the file to be loaded when I make my selection on the drop-down.

Thanks
JG2112Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sint4xCommented:
Well if you think about it, loading files requires server side capabilities, therefore they must be loaded before the page is rendered. Thus, you need to load the files into say.. a <div> and then onchange you display the desired div and hide the rest:

Example:

<script>
lstFiles = new Array("gB_Loc.dat");

function ChangeFile( filename )  {
      for( i = 0; i <= lstFiles.length; i++ ) {
        if( filename == lstFiles[i] ) {
              document.getElementById( filename ).style.display = 'list-item';
        } else {
                        document.getElementById( filename ).style.display = 'none';

      }
}

</script>
0
sint4xCommented:
Sry hit the wrong button on my laptop (stupid touchpad)

That script doesnt work^^

<script>
lstFiles = new Array("gB_Loc.dat"); // List all ur files here

function ChangeFile( filename )  {
     for( i = 0; i <= lstFiles.length; i++ ) {
       if( filename == lstFiles[i] ) {
             document.getElementById( filename ).style.display = 'list-item';
       } else {
             document.getElementById( filename ).style.display = 'none';
       }
     }
}

</script>

                <select size="1" name="vcat" >

     <!--[OPTIONS]-->
     <Option value="gb_Dis.dat" onChange="ChangeFile(this.value);">Disabled Access</option>
                <Option value="gb_Loc.dat">Local Information</option>
                <Option value="gb_Wea.dat">Weather</option>
                <Option value="gb_Cur.dat">Currency</option>
                <Option value="gb_Apa.dat">Apartments</option>
                <Option value="gb_Res.dat">Restaurants</option>
                <Option value="gb_Com.dat">Complex</option>
                <Option value="gb_Lei.dat">Leisure &amp; Entertainment</option>
                <Option value="gb_Act.dat">Activities for Kids</option>

              </select></td></tr>

    <!-- now u need to dynamically load your files into divs  with the corresponding filenames as the ids, make sure you have them set to hide on default -->

    <div id="gb_Loc.dat" style="display: none">gb_Loc file contents</div>

   <!-- .... other files as well -->

Hope this helps
0
JG2112Author Commented:
I tried what you said - however nothing happens after dropdown item selected! Where must the divs go - sorry but I dont know PHP - very new!!
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

sint4xCommented:
that is more javascript then php, what browser are you using?
0
JG2112Author Commented:
IE 6
0
sint4xCommented:
errr..

Put 'onChange="ChangeFile(this.value);">'

on the SELECT tag not the option tag.


Sorry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.