tags:

views:

38

answers:

3

Hi,

i want to make two links. 1. click here to generate CSV file. 2. click here to download the CSV file.

the problem is that i want the second file to appear only if the first link was clicked.

can someone help?

thanks, Sebastian

EDIT: i forgot to mention that my table is built up in a while statement.

+2  A: 

Why not have just one link that would generate the CSV file and offer it for download? You can stream files directly to the browser, you don't have to necessarily save them to disk or access them by direct URL.

Your method would be unnecessarily complex and I don't see any reason in doing so. If I've misunderstood your goal somehow, please correct me.

Tatu Ulmanen
how can i do that?i seemed the logical way for me, that's why i asked.
sebastian
How? See my answer to a related question: http://stackoverflow.com/questions/202305/create-php-dom-xml-file-and-create-a-save-file-link-prompt-without-writing-the-fi/204074#204074
Jon Cram
A: 

Normally , i would do a ajax call to a php script.

It would create the CSV and return the name of the file.

with jquery it should be something like :

$('#download').click( function() {
   $.ajax({
    type: "POST",
    url:"/createcsv.php",
    success: function(data) {
      window.open("http://www.example.com/" + data , "download");
    }
   });
});
racar
A: 

try something like this:

<a href="" id="test1" OnClick="func(); return false;">Generate CVS</a>
<script type="text/javascript">
function func(){
var a = "<br><a href=\"\" id=\"test2\">Download CVS</a>";
document.write(a);
}
</script>
Keshan