<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anatoly</title>
    <description>The latest articles on DEV Community by Anatoly (@anatoly121).</description>
    <link>https://dev.to/anatoly121</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1212458%2F15678d41-0e1d-4523-b1a5-3b18626e0a7f.png</url>
      <title>DEV Community: Anatoly</title>
      <link>https://dev.to/anatoly121</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anatoly121"/>
    <language>en</language>
    <item>
      <title>Simple VAT Calculator On JS</title>
      <dc:creator>Anatoly</dc:creator>
      <pubDate>Fri, 17 Nov 2023 18:13:46 +0000</pubDate>
      <link>https://dev.to/anatoly121/simple-vat-calculator-on-js-2pd4</link>
      <guid>https://dev.to/anatoly121/simple-vat-calculator-on-js-2pd4</guid>
      <description>&lt;p&gt;This simple &lt;a href="https://vatcalcfree.com/"&gt;VAT calculator&lt;/a&gt; allows users to enter the amount and the VAT rate. In one click, the VAT amount and total amount appear on the screen. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NeCYd8x6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qof0hgog3rx7mdakbt35.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NeCYd8x6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qof0hgog3rx7mdakbt35.JPG" alt="Image description" width="350" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML CODE:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;link rel="stylesheet" href="styles.css"&amp;gt;
    &amp;lt;title&amp;gt;VAT Calculator&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div class="calculator"&amp;gt;
    &amp;lt;h2&amp;gt;VAT Calculator&amp;lt;/h2&amp;gt;
    &amp;lt;label for="amount"&amp;gt;Amount (excluding VAT):&amp;lt;/label&amp;gt;
    &amp;lt;input type="number" id="amount" placeholder="Enter amount" required&amp;gt;

    &amp;lt;label for="vatRate"&amp;gt;VAT Rate (%):&amp;lt;/label&amp;gt;
    &amp;lt;input type="number" id="vatRate" placeholder="Enter VAT rate" required&amp;gt;

    &amp;lt;button onclick="calculateVAT()"&amp;gt;Calculate VAT&amp;lt;/button&amp;gt;

    &amp;lt;div class="result"&amp;gt;
        &amp;lt;p&amp;gt;VAT Amount: &amp;lt;span id="vatAmount"&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Total Amount (including VAT): &amp;lt;span id="totalAmount"&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;CSS Code:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f4f4;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.calculator {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

label {
    display: block;
    margin-top: 10px;
}

input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
}

button {
    background-color: #4caf50;
    color: #fff;
    padding: 10px;
    margin-top: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.result {
    margin-top: 20px;
    font-weight: bold;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;JS Code:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function calculateVAT() {
    const amount = parseFloat(document.getElementById('amount').value);
    const vatRate = parseFloat(document.getElementById('vatRate').value);

    if (isNaN(amount) || isNaN(vatRate)) {
        alert('Please enter valid numbers for amount and VAT rate.');
        return;
    }

    const vatAmount = (amount * vatRate) / 100;
    const totalAmount = amount + vatAmount;

    document.getElementById('vatAmount').innerText = vatAmount.toFixed(2);
    document.getElementById('totalAmount').innerText = totalAmount.toFixed(2);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have any questions or suggestions, please comment on this post.&lt;/p&gt;

</description>
      <category>vat</category>
      <category>calculator</category>
      <category>calc</category>
    </item>
  </channel>
</rss>
