-1

I am new to javascript, I need help with the following. I have a html file with a htmlform on top followed by a table, that i filtered using checkboxes. I am trying to write a function to download the html form and the filtered values of table with header as one csv file or a xml file. Final goal is to have it as xml file, but if i can get a csv file, i can parse it and convert to a xml file. I tried following the discussion at How to create and download an XML file on the fly using javascript? but it was not of much help.

html form looks like this

<html>
<form>
<fieldset>
Item ID:<input type="text" name="name">
<br>
Country:<input type="text" value="US">
<br>
Zip:
<div>
<label for="msg">Message:</label>
<textarea id="msg" name="user_text</textarea>
</div>
</fieldset>
</form>
</html>
Tim
  • 45
  • 8
  • What you need to do is make a request to server with that data as the payload, then use the payload to write a file, then send back to client for download. However, without any more information there's not a lot anyone can help you. – Isaac Vidrine Mar 11 '19 at 17:24
  • I want to download entire web page after filtering as a xml file – Tim Mar 11 '19 at 17:48

1 Answers1

0

If you want to be able to download a table in csv using only javascript, you should take a look at datatables. They have a very good library and have a extension to download the table as CSV and Excel all from the front end.

The extension is called Buttons you can find it Here.

Vidal
  • 2,605
  • 2
  • 16
  • 32
  • I have a html-form on top of the table, even that needs to be downloaded along with the table in the same csv file. @vidal – Tim Mar 11 '19 at 17:39
  • How are you going to organize the form on the csv ? or how you want it ? – Vidal Mar 11 '19 at 18:19
  • I want the form on top and then followed by the table. somehting like this @vidal html form ........... ........... .......... Table a b c 0 1 2 3 1 4 5 6 2 7 8 9 – Tim Mar 11 '19 at 18:37