Store Data in an HTML file - html

Wanted to know if the following scenario is possible -
I have some data that is in an excel file. I want to make an html page which will have this data inside it (no other source of data). And inside the Html page, will I be able to put textfields, buttons etc for a user to input data and based on that, i need to write queries (jqueries i guess) to show the data that is the result of those queries
Can this be done? I have not done anything so far. I just wanted to know if this is possible and please someone point me in the right direction for me to start. I wanna learn on my own how to do this.
Thanks in advance.

HTML is a markup language - it is the structure of a webpage, and has no mechanisms for storing or processing dynamic data.
You will have to use a client-side language JavaScript + cookies, or a server-side language like PHP + MySQL.

You want to look at using JavaScript in the page. On the server (I presume) you need to read the Excel file, and generate JS objects on the page that hold the values. That is, the JS when run creates a collection of JS objects with the values in it. This script can be embedded in the page so that no other data access is needed.
You can then write more JS linked to the buttons that select data out of these objects, and displays them on the page. You probably don't want to do this from scratch -- there are good JS libraries and frameworks to leverage. Consider either GWM or YUI.

Perhaps the simplest way is to open the file in Excel and save it as text (tab-separated; comma-separated would do, too), then insert this text data into your HTML document between the tags <script type="text/plain"> and </script>. You can then write, in a rather straighforward way, JavaScript code that reads the content of this element and constructs a JavaScript array of objects (or some other suitable data structire) from it. It will then be easy to access the data in JavaScript.
This will make it possible to run queries and display data. Modifying the data would be a completely different matter.

Related

Can we save from/input data to same html file

I have a requirement where I need to produce data in table format and send the html file to team.
For example:
Column 1
list of jobs running
I have created the above with the help of HTML table.
I need to add another column "Remarks" where user can update their remarks and save the html file and share it with the team.
Is it possible with HTML, if yes may I know how to achieve this ?
I am new to HTML, please excuse me if my question is silly.
No.
HTML is a data format. You need a programming language.
Typically this would be handled by using an HTML form, which POSTs data to an HTTP server where server-side code (written in the programming language of your choice) would store it in a database.
The HTML document with the table would be rendered on demand using data from the database.
Normally, you would share a URL to the HTTP server rather than the HTML document itself (although you could download it and then share it).
Yes , it is possible to make changes to your own html but you need a scripting language to do so.
I would recommend you to use Javascript which allows you to change html tags values based on the user input.
using the document.getElementById().innerHTML you can easily change the value of html tags..
Here is a link which will expalin this topic much more elaborately.
https://www.w3schools.com/jsref/prop_html_innerhtml.asp

how to retrieve the data from xml and display it in table in html

I wanted to develop a small search website where I will be storing the data in XML files. When we search anything, it should display those data as table format in html. How does one retrieve the data from XML files?
Below is the basic thing to display data of only two columns, but I want to display data dynamically:
html file:http://www.w3schools.com/xml/xml_applications.asp
This is the sample code for retrieving the data from xml only for two columns.
Well the first problem I see is that you have two functions in there that are not being called. Nothing programmatic will happen in this scenario. When you have a method you need to call said method with myFunction(). I would recommend reading up a little more on javascript instead of copying and pasting it and expecting it to just "work"
To further elaborate, you removed the function call from the example you took when you took off the button. What is your xml endpoint? (it's not going to be the same as the example unless you build it to be that way). In this example it's just an xml file that is hosted on the server with the same root as the html.

Using a JSON file instead of a database - feasible?

Imagine I've created a new javascript framework, and want to showcase some examples that utilise it, and let other people add examples if they want. Crucially I want this to all be on github.
I imagine I would need to provide a template HTML document which includes the framework, and sorts out all the header and footer correctly. People would then add examples into the examples folder.
However, doing it this way, I would just end up with a long list of HTML files. What would I need to do if I wanted to add some sort of metadata about each example, like tags/author/date etc, which I could then provide search functionality on? If it was just me working on this, I think I would probably set up a database. But because it's a collaboration, this is a bit tricky.
Would it work if each HTML file had a corresponding entry in a JSON file listing all the examples where I could put this metadata? Would I be able to create some basic search functionality using this? Would it be a case of: Step 1 : create new example file, step 2: add reference to file and file metadata to JSON file?
A good example of something similar to what I want is wbond's package manager http://wbond.net/sublime_packages/community
(There is not going to be a lot of create/update/destroy going on - mainly just reading.
Check out this Javascript database: http://www.taffydb.com/
There are other Javascript databases that let you load JSON data and then do database operations. Taffy lets you search for documents.
It sounds like a good idea to me though - making HTML files and an associated JSON document that has meta data about it.

Strategy searching and using csv values from html

i am pretty new to html and as part of project we have to create a game where the player has to select different tags and then gets rewarded according to a value which is stored in a .csv file.
I created the layout so far with diffrent buttons, now i want to know how can i search inside the csv file and return the corresponding value? I am using html and javascript so far.
There are about 6000 entries in this file. Is it wise to load them all into an array?
And how can i share variables between functions without calling them one after the other?
For example to find out how often a button was pressed i obviously could not use a var in a script since it would be lost after the script was executed so i had to create a html input text field to store the variable constantly.
Your help is appreciated :)
Regards,
Marcurion
It would be wise to use a DBMS, however if the project requirement is to use CSV you could use a server side programming language like PHP to read and write the CSV file.
I wouldnt recommend to load all entries in the array, instead you could only load what you need but this can be achieved by using a DBMS.
To share variables between functions on javascript you will need to declare them as global variables, you could google: "javascript variables scope" or "javascript global variables" and read a little more of scopes.
If you want to know how often the button was pressed you can make AJAX requests to a server side script that can handle what you need if the script needs to be submited or executed.
You could check out JQuery framework to use events, ajax and infinite other things.
My advice is for you to read a little more about javascript, a framework for javascript like JQuery and a little of server side languages like PHP, with these tools you can easily develop what you need.

How can I create PDF output from rrdcgi?

I have created a rrdcgi script to display information about the system performance with graphs. Now I would like to add an option for the users to create PDF on the fly with the details on current page (images and information) and header and footer. I also want the generated PDF files to be saved in some location so that that can be easily accessed next time. Is this possible to do with rrdcgi or any Perl code would be really appreciated.
I need this options
You need to consider what you want to put in the PDF: Do you want an exact replica of the web page the user is viewing (too hard to be close to impossible without having the user's browser installed on your side and using its print output) or do you want the same information in a roughly similar layout?
An important issue is how you are generating the HTML: I did something similar once to generate PDF receipts for experiment participants (now, I just output HTML with print styles).
The HTML is generated using HTML::Template although Template.pm would be just as fine.
It is then trivial to write another template, one that generates a LATEX document which can be processed using pdflatex. If you save the data the time the snapshot is requested, you can add the snapshot to a queue that generates documents asynchronously so that requests do not tie up the web server.
Update: Looking at rrdcgi, I now realize that it already does use a template. That is perfect: Instead of putting HTML in the template, put LATEX code in the template and run rrdcgi with the --filter option to create a LATEX source file which you can run through pdflatex. I guess the problem to solve there is to be able to use the exact same data that was used to generate the page the user is looking at.
If it is not possible to re-run rrdcgi with the exact same data, consider adding some JavaScript that submits the HTML source of the page the user is reviewing (or some JSON representation thereof) to a CGI script that parses the HTML and outputs LATEX. Writing clean HTML in the original template and judicious use of class and id attributes would help there.
I do not have time to test any of these ideas right now, but I will take a look again within the next couple of days.
Is it worth the effort?
Why don't you add a FAQ explaining how to setup a PDF-printer on Windows/MAC/Linux and provide a 'clean' page that can then be printed?
Since you apparently have to create the PDF,
take a look at this (what-is-the-best-perl-module-to-use-for-creating-a-pdf-from-scratch) post here on SO.
There is also this post, that could combine the 'clean' HTML page and a server-side print.
Regarding the LaTeX route, if you have rrdcgi generate graphs in pdf format, pdflatex will be able to integrate them directly into the document, producing super quality pdf with graphs ... very slick. Sorry, no code.