I implemented some design changes to my table, only to find that it completely malfunction

I've created an order form using Java and HTML/CSS, everything was running smoothly until I decided to add some styling to the code. Now, it seems like the form doesn't reset properly post-submission; in fact, it's not responding at all. It's probably a minor issue but I can't seem to locate it even when checking the JavaScript console.

The form should display the total amount, and I also need to implement a discount that is only applicable on Mondays and Fridays.

    !DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Order Form</title>
    <link href="pl.css" rel="stylesheet">
    <style>




    </style>
</head>
...

Javascript

<script>

    var qtyBoxA = document.getElementById('QtyA');
    var qtyBoxB = document.getElementById('QtyB');
    var qtyBoxC = document.getElementById('QtyC');
    var qtyBoxD = document.getElementById('QtyD');
    var totBoxA = document.getElementById('TotalA');
    var totBoxB = document.getElementById('TotalB');
    var totBoxC = document.getElementById('TotalC');
    var totBoxD = document.getElementById('TotalD');

    var grandTot = document.getElementById('grandTotal');
    var btnGetTot = document.querySelector("input[type=button]");
    var btnReset = document.querySelector("input[type=reset]");

    ...
</script>
</body>
</html>
@charset "UTF-8";
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700);

body {
    font-family: 'Open Sans', sans-serif;
    font-weight: 300;
    line-height: 1.42em;
    color:#A7A1AE;
    background-color:#1F2739;
}

h1 {
    font-size:3em;
    font-weight: 300;
    line-height:1em;
    text-align: center;
    color: #4DC3FA;
}
...

Answer №1

Once the necessary adjustments were made to your code, everything is now working smoothly :) The primary issue stemmed from the logic within your code; you essentially copied it without truly understanding how it functions. You were trying to retrieve an element that did not exist:

var grandTot = document.getElementById('grandTotal');
. Consequently, the rest of the code in getGrandTotal() was failing due to a null error.

To resolve this, I included the following line in the HTML and created the corresponding element with the ID grandTotal:

<td id="grandTotal"></td>

 // JavaScript code remains the same
      

CSS Snippet:

@charset "UTF-8";
      @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700);

// CSS styles continue as usual

Solution: Everything has been resolved! Your pizza order form should function seamlessly now :)

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

Is it acceptable to debut a full-screen iframe widget compared to an embedded one?

My current project involves integrating a custom widget into users' websites for my application. I am considering using an iframe as it seems to be the most efficient option for several reasons: Utilizing the custom framework of the application will ...

Create a CSS header with a fading background that extends horizontally to the left and right

I'm looking to create a header with a unique color transition effect - a left fade from light blue to blue, a center that is solid blue, and a right fade from blue to light blue. The header should span the full width of the page. Can anyone suggest th ...

Chrome does not support href while Edge does

href seems to be causing issues in Chrome, but it works fine on Microsoft Internet Explorer or Edge. It appears that the line (a href="....html")Something(/a) is not functioning properly on edge or safari. It behaves like a dropdown menu. There is a sig ...

Challenges encountered during the updating of nodes in 3D force graphs

I am currently developing an application where users can utilize a dat.gui menu to customize their Three.js animation. Specifically, I am implementing the 3d-force-graph library. Whenever a user makes a change, the following steps are taken: Swap out the ...

The ellipsis styling is being ignored

Check out the code provided below. It pertains to the text box located in the top right corner, which reveals a drop-down box when clicked. My intention is for long text in this box to be truncated with ellipsis using text-overflow:ellipsis. From my unders ...

Issue with Ajax response and JSON parsing in Jquery

I recently made a POST call to a Rest API for logging in and received a successful response with various data. To confirm the information and determine what details I need to keep, I decided to log this data. Here is the code snippet I used: $.aja ...

html nested table with merged columns

I've come across this issue before, but I just can't seem to figure out how to implement a multi-layered colspan in an HTML table. The HTML table I'm working with is from w3schools, but I want to create a colspan of 2 for Data 2 and Data 5. ...

Is it possible to use personalized fonts alongside Google web fonts?

I'm looking to incorporate my customized font into a website using Google's font loader. Any recommendations on how to achieve this? ...

Positioning a div relative to another div using the pos:fixed attribute

Is there a way to make a fixed position div relative to its parent div instead of the window using only CSS? I want a sticky block that follows the content while scrolling with the page, and stays in place even when the window is resized. I know this can ...

Finishing a division by both clicking outside of it and pressing a button

I am currently working on setting up a dropdown menu that can be closed both by clicking outside the opened div and by clicking the button or image that opens the div. Image with onclick function: <img onclick="hide()" id="menu" src="...."> Th ...

Problem encountered while attempting to insert chunk data into an array correctly with Node.js

I am currently working on a project where I need to read a text file and store each word in an array using Node.js. However, I am facing difficulties as my current code is not producing the desired result. Below is an overview of my txt file. CHANGES: C ...

The HTML5 video element is not functioning properly on iOS devices

<video preload="true" controls="true" style="width:100%;" id="video-banner" poster="poster-img.png"> <source src="video.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> I have the following code to displ ...

How can I make text wrap instead of overflowing to ellipsis in a list when using vue-material?

Question: <md-list-item> <md-icon v-bind:style="{color: transcript.color}">account_circle</md-icon> <div class="md-list-item-text"> <p>{{ transcript.text }}</p> </di ...

CSS Navigation Bar Fails to Function Properly on Mobile Devices

Check out the plunkr I have created by visiting: http://plnkr.co/edit/gqtFoQ4x2ONnn1BfRmI9?p=preview The menu on this plunkr functions correctly on a desktop or laptop, but it doesn't display properly on a mobile device. I suspect that the issue may ...

Using conditional CSS values in Angular 8

I am currently working on a parent component and child component setup, where I am utilizing the child component's selector to display it within the parent component. Here is my child component's HTML: <div class="main-container" [n ...

Can React Router be integrated with Material UI tabs?

I have made some changes to the code of the Tabs component in material ui, <AppBar position="static"> <Tabs variant="fullWidth" value={value} onChange={handleChange} aria-label="nav tabs example" > < ...

Error: Unable to locate module: Issue: Unable to find '../components/charts/be.js' in '/vercel/workpath0/my-app/pages'

Having some trouble deploying my next.js app through Vercel. Everything works fine locally with the command 'npm run dev'. But when attempting to deploy it on Vercel using a Github remote repository, I encountered the following error: 18:07:58.29 ...

Resolution for Vue3: Understanding why a component instance's template ref cannot locate a defined function

LoginInfo.vue <script setup lang="ts"> import { rules } from './config/AccountConfig' import { reactive } from 'vue' import { ref } from 'vue'; import { ElForm } from 'element-plus'; const info = reac ...

Delay in Response of OnTextChanged Event in ASP.NET

The functionality is there, but it doesn't respond immediately. It only works when I click on something. I attempted using the onkeyPress method as well: <asp:TextBox ID="txtWriter" runat="server" onkeyPress="txtOnKeyPress" ></asp:TextBox& ...

What is the process for transforming the outcome of a Javascript function into a webpage containing solely a JSON string?

I have a specific requirement where I need to fetch a URL and ensure that the only content displayed on the page is a JSON string. For instance, let's say I created a basic function called getDayOfWeek() to determine the current day of the week. The ...