thak123 0 Newbie Poster

I want to get a pop like save As in a HTML page .In the Page i am writing all my data And I append it to a variable .

And i attach it to a tag in the page which is the hyperlink to save the file .

I tried Some code.But i am getting a part file with name which i cannot modify
.
I want to rename the File and Save it as CSV file..

My auto click is not working.

Function ExportData()
            {
                var result = "";
                var keyinput,valinput;

                if(!localStorage.length==0)
                {
                    for (i=0; i<=localStorage.length-1; i++)
                    {

                        keyinput=localStorage.key(i);/// make dynamic: store pageno as key.

                        valinput=localStorage[keyinput]; //make dynamic: store user response these forms(textbox,slider,date,time,radio)

                        result+=keyinput+','+valinput+'\r\n';

                    }
                    result+="Finish";

                    var exportLink=document.createElement("a");
                    var t=document.createTextNode("sangath.csv");

                    exportLink.setAttribute('href', 'data:text/csv;base64,' + window.btoa(result));
                    exportLink.setAttribute('id', 'rollno');
                    exportLink.appendChild(t);
                    document.getElementById("result").appendChild(exportLink);
                    alert("generated csv");
                    document.getElementById('rollno').click();
                    alert("autoclicked");
                }
                else
                {
                    alert("No items stored yet....");
                }
            }