Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-03-24
6
Medium Priority
?
268 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:JG2112
  • 4
  • 2
6 Comments
 
LVL 4

Expert Comment

by:sint4x
ID: 13626797
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
 
LVL 4

Expert Comment

by:sint4x
ID: 13626836
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
 

Author Comment

by:JG2112
ID: 13626992
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:sint4x
ID: 13627304
that is more javascript then php, what browser are you using?
0
 

Author Comment

by:JG2112
ID: 13629058
IE 6
0
 
LVL 4

Accepted Solution

by:
sint4x earned 200 total points
ID: 13630359
errr..

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

on the SELECT tag not the option tag.


Sorry
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question