Created
April 18, 2018 16:24
-
-
Save shoya140/d82796f6c371f5e6b3efdc74e186060e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#save-button').on('click', function () { | |
const data = [ | |
['name', document.getElementById('name-input').value], | |
['email', document.getElementById('email-input').value], | |
['age', document.getElementById('age-input').value] | |
] | |
var csv = 'id,value' | |
data.forEach(function(row) { | |
csv += '\n' | |
csv += row.join(',') | |
}) | |
const hiddenElement = document.createElement('a') | |
hiddenElement.href = 'data:text/csvcharset=utf-8,' + encodeURI(csv) | |
hiddenElement.target = '_blank' | |
hiddenElement.download = 'meta_'+Date.now()+'.csv' | |
hiddenElement.click() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment