HTML - counting the number of responses from a text file

In summary, the conversation discusses how to count the number of responses from a text file in an angelfire website. The participants suggest using a file to store the counter or creating a program to parse the inputs and calculate the responses. They also mention the limitations of using certain languages on the website.
  • #1
jjiimmyy101
74
0
HTML -- counting the number of responses from a text file

Hello,

I have an angelfire website and on one of my pages I ask a simple question. What is your shirt size? There are four options: Small, Medium, Large and Extra Large. The answer is then submitted to a text file.

My problem is that I would like to be able to keep track of how many times people respond with "Small" or "Medium" or "Large" or "Extra Large" in a different text file. I've attached a sample of what kind of output I'm looking for (or anything similar to this), if my description isn't clear. I don't want to manually count the responses like I have been doing.

Is there anyway to accomplish this, keeping in mind that angelfire will not allow me to add any of my own cgi, php, asp, etc. (I can however use Javascript on angelfire, but I am not that comfortable with it).

Any suggestions would be appreciated.

Jimmy
 

Attachments

  • actual text file.txt
    429 bytes · Views: 421
  • HTML code used to obtain the text file.txt
    519 bytes · Views: 214
  • What I'm looking for.txt
    49 bytes · Views: 427
Technology news on Phys.org
  • #2


#1) Use a file to store the counter.
Modify file each time request is made

#2) Do the calculation on your computer. Make a program to parse the inputs .. So just make files go through that program instead of reading them directly
 
  • #3


Dear Jimmy,

Thank you for your question. It is possible to count the number of responses from a text file using HTML and JavaScript. Here are the steps you can follow:

1. Create a new HTML file and name it "count_responses.html". This will be the file where you will display the results.

2. In this HTML file, create a table with four columns: "Size", "Number of Responses", "Percentage", and "Bar Graph". This will be the format in which you will display the data from the text file.

3. Next, add a JavaScript function that will read the text file and count the number of responses for each size. You can use the XMLHttpRequest object to read the text file and the split() method to separate the responses by size.

4. Once you have the count for each size, you can calculate the percentage and display it in the "Percentage" column of the table.

5. To create the bar graph, you can use HTML <div> elements with inline styles to set the width of each bar based on the percentage calculated in the previous step. You can also use a different color for each bar to make it visually appealing.

6. Finally, you can use the onload event of the <body> tag to call the JavaScript function and display the results when the page loads.

I hope this helps. Please let me know if you have any further questions.

Best,
 

1. How can I count the number of responses from a text file using HTML?

Unfortunately, HTML is not a programming language and does not have the capability to count the number of responses from a text file. You will need to use a server-side language such as PHP or JavaScript to accomplish this task.

2. Can I use HTML to parse and analyze data from a text file?

No, HTML is not designed for data parsing and analysis. You will need to use a server-side language or a specialized tool like a scripting language to perform these tasks.

3. Is it possible to display the number of responses from a text file on a webpage using HTML?

No, HTML is a markup language used for creating the structure and layout of a webpage. It cannot be used to dynamically display data from a text file. You will need to use a server-side language or a combination of HTML and JavaScript to achieve this functionality.

4. How can I retrieve data from a text file and store it in an HTML document?

HTML does not have the ability to retrieve data from a text file. You will need to use a server-side language or a combination of HTML and JavaScript to retrieve and display data from a text file on a webpage.

5. Can I use HTML to manipulate and perform operations on data from a text file?

No, HTML is not capable of manipulating or performing operations on data from a text file. You will need to use a server-side language or a specialized tool for data manipulation and operations.

Similar threads

  • Programming and Computer Science
Replies
5
Views
365
  • Programming and Computer Science
Replies
21
Views
519
  • Programming and Computer Science
Replies
24
Views
1K
  • Programming and Computer Science
Replies
17
Views
5K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
16
Views
2K
  • Programming and Computer Science
Replies
1
Views
8K
Back
Top