Struggling to save HTML form data to a text file, despite spending the past two hours attempting different methods without success

As mentioned in the title, I am attempting to retrieve the results from the form displayed below:

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
  <script>
/* Facing difficulties with this section */
  </script>
</head>
<body>
<h1 style="color:#e6e8e8">Video Game Form</h1>
<form id="form" class="form">
  <div class = "form-control">
    <label>All Time Favorite Game:</label>
    <input name="allgame" id="allgame" type="text" placeholder="Enter your favorite game">
    <label>Favorite Free Game:</label>
    <select name="freegame" id ="freegame">
      <option>Select your favorite game</option>
      <option>Fortnite</option>
      <option>Apex Legends</option>
      <option>Call of Duty: Warzone</option>
      <option>Valorant</option>
      <option>Rocket League</option>
    </select>
  </div>
  <div class="form-control">
    <label>More games you may play
        <small>(Check all that apply)</small>
    </label>
    <label>
        <input type="checkbox"
            name="inp">Minecraft</input></label>
     // remaining checkboxes removed for brevity 
        <button type="submit" value="button" class="neon-button">
    Submit
  </button>
</form>
</body>
</html>

This is a fundamental form as part of my journey into web development, however, I currently find myself at an impasse. If anyone can assist me in capturing and saving the results into a text file within the same directory as the HTML and CSS files, it would be greatly appreciated.

Answer №1

To properly handle the submission of your form, ensure that you include an action attribute in your script tag. Additionally, you can manually retrieve the value of each input element by clicking a select button. Keep in mind that if you intend to save the results to a text file, server-side functionality will be necessary as client-side JavaScript cannot write to server files due to security restrictions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for dealing with a div that needs to be contained within another element with scrollbars?

I am facing an issue with a div that has specific dimensions (height:x; width:y; overflow:auto;) and displays the content of an article. The problem arises when the content exceeds the div's limits, causing a scrollbar to appear for navigation. Withi ...

Error: Client was unable to process JSON data

My server setup looks like this: var http = require('http'); //Defining the port to listen to const PORT=8092; //Function that handles requests and sends responses function handleRequest(request, response){ response.statusCode = 200; ...

Steps for retrieving multiple documents from Firestore within a cloud function

In my cloud function, I have set up a trigger that activates on document write. This function is designed to check multiple documents based on the trigger and execute if/else statements accordingly. I have developed a method that retrieves all documents u ...

Steps to send an asynchronous AJAX request to the server-side within the JQuery validation plugin using the addMethod() function

Currently, I am in the process of developing my own framework using the JQuery validation plugin to validate CRUD forms both client-side and server-side. It is crucial that these forms are not static but rather created dynamically using "handlebar.js". Fo ...

Encountered a problem while attempting to generate JSON data on Spring 3.2, resulting in a "Page not found 404" error

I am currently working on retrieving data from a database using Sprng 3.2 and myBatis with the goal of receiving the data in JSON format. In order to achieve this, I have included jackson-core-asl, jackson-core-lgpl, and jackson-mapper-asl(1.9.13) in the ...

Retrieve a portion of a webpage from a separate file

Is there a way to load part of a page from another HTML/PHP file? Here's my current situation: I have a PHP file that contains: $dirname = dirname(__FILE__); //Path to your *.php file $file = $dirname."/enmainheader.php"; $contents = file($file); ...

Issue with icons not properly expanding and collapsing in accordion display

Currently, I am in the process of constructing an accordion that consists of multiple children and showcases an open/close icon upon clicking. The concern I am facing revolves around the behavior of the icons. Everything works smoothly when expanding and ...

Bringing in the bootstrap JavaScript file

I've recently started using Bootstrap that I installed from npm, but I'm having trouble importing the JS file. This is my main JS file where I want to utilize all the tools: import * as bootstrap from '../node_modules/bootstrap/dist/js/boot ...

Storing JSON data in an array is a simple process that involves converting

Currently, I am working on implementing dependent dropdowns using JavaScript. The dropdowns include country, state, and city, with the data sourced from the JSON data provided below. My goal is to organize the data in such a way that countries are stored ...

Discrepancy between Laravel Vue: console logging Axios POST response and network response apparent

https://i.stack.imgur.com/vO05x.png Within my Laravel vue app's backend, I am noticing an inconsistency in the data being sent and received. Even though the data is supposed to be the same, the two console logs are showing slight differences. DATA ...

Issue with jQuery Quicksand's CSS rendering in Internet Explorer and Firefox browsers, but not affecting Chrome

I'm attempting to achieve an icon-swapping effect using jQuery+quicksand. Although it works seamlessly in Chrome, I am encountering issues with IE and Firefox. Given that the more intricate quicksand demos function flawlessly across all browsers, I su ...

Tips for aligning text at the bottom of a div that has been floated to the right alongside another div

I have a parent container with two child divs inside; one div is floated to the left and the other is floated to the right. Here is my current layout: ┌─────────────┬─────────────┐ │ Text left ...

I'm having trouble with fixing the TypeError that says "Cannot read properties of undefined (reading 'style')." How should I address this issue

I'm having trouble with a slideshow carousel on my website. When the site loads, only the first image is shown and you have to either click the corresponding circle or cycle through all the images using the arrows for the image to display. I'm al ...

What could be causing my tabs to shift to the vertical side when using large, larger, and wide screens?

In my previous research, I came across a question similar to mine: Pure CSS accordion not working within CSS tabs. The solution mentioned works perfectly on monitors of any size, but the difference lies in the use of the a element. In their code, setting t ...

Enhancing stroke precision and aliasing in SVG images

Need help creating sharp 1px thick black lines for an animated speech bubble using SVGs. The anti-aliasing on the strokes isn't crisp and has a smudged look, despite efforts to fix it by rounding calculations. What can be done to achieve clean, precis ...

Layer several divs inside a main div

I'm grappling with a simple issue and could use some help to resolve it. Utilizing bootstrap, below is my CSS and div structure. How can I achieve an overlap of DIV 1, DIV 2, and DIV 3? Essentially, I want to position them on the same level, one behi ...

"Exploring the powerful combination of Django dynamic formsets and the magic

While utilizing django dynamic formset and ajax to check the inventory, I encounter a challenge when trying to make ajax detect changes on newly added forms. How can I achieve this? Dealing with dynamically added forms $('#form-inline tbody tr' ...

Set default selected value for dropdown list using radio buttons

Could anyone provide guidance on how to reset a dropdown list value using a radio button selection? Specifically, I need the dropdown list to reset to its default "selected" option when a particular radio button is clicked. Any recommended approaches usin ...

What's the best way to retrieve information from Mongodb in order to generate a map marker?

I have a map where I need to place markers. I've created a collection in MongoDB and have a sample data set ready for the marker. However, I am having trouble retrieving the data and actually creating the marker on the map. The Map Meteor.star ...

Is there a way to avoid overlapping in CSS3 transforms?

Check out my jsfiddle demo: http://jsfiddle.net/WLJUC/ I have noticed that when you click to rotate the larger container, it overlaps the smaller one. This poses a problem as I am attempting to create a picture gallery where users can rotate and enlarge ...