0

I have a table where each cell is a textfield. On clicking of a button, I want to collect the values from this table, row by row, and write it in a csv file.

For example, consider the below table. enter image description here I want to create a file like text.txt, with the following content:

abc,def,ghi
jkl,mno,pqr
uvw,xyz,123

I know we can't use JavaScript in HTML to create and write into a file due to a lot of permission issues, so I want to extract the values and pass an array to a python script that will create the file.

I had a look at this question, but there, the onclick function is purely calling the python script. I need to first extract the values using javascript, and then call the python script. How do I proceed?

Community
  • 1
  • 1
Randomly Named User
  • 1,889
  • 7
  • 27
  • 47
  • You make an AJAX call to the python script on the server. Your webserver will need to be able to execute Python (e.g. apache with mod-python). – Jared Smith Jun 21 '16 at 11:30

1 Answers1

0

You need to do two things.

1) Write a javascript function to serialize your data and send it via POST to your script.

2) Write your python script and host it on your web server, ensuring that it takes in the data required to update your table.

How you implement step one will depend on the HTML in your page. (have you actually started to implement it yet?)

https://api.jquery.com/serialize/

Danny Cullen
  • 1,782
  • 5
  • 30
  • 47