Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Alright sorry, I thought you were looking for some complex code. Here is a simple example of exactly what you're looking for.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script&gt; function doMath() { var totalparts = parseInt(document.getElementById('parts_input').value); var labor = parseInt(document.getElementById('labor_input').value); var misc = parseInt(document.getElementById('misc_input').value); var subtotal = totalparts + labor + misc; var tax = subtotal * .13; var total = subtotal + tax; document.getElementById('subtotal_input').value = subtotal; document.getElementById('tax_input').value = tax; document.getElementById('total_input').value = total; } &lt;/script&gt; &lt;div&gt;Total Parts: &lt;input type="text" id="parts_input" value="1" readonly="true" /&gt;&lt;/div&gt; &lt;div&gt;Labor: &lt;input type="text" id="labor_input" onBlur="doMath();" /&gt;&lt;/div&gt; &lt;div&gt;Misc: &lt;input type="text" id="misc_input" onBlur="doMath();" /&gt;&lt;/div&gt; &lt;div&gt;Sub Total: &lt;input type="text" id="subtotal_input" readonly="true" /&gt;&lt;/div&gt; &lt;div&gt;Tax: &lt;input type="text" id="tax_input" readonly="true" /&gt;&lt;/div&gt; &lt;div&gt;Total: &lt;input type="text" id="total_input" readonly="true" /&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Obviously this doesn't grab the dynamic value from a database. If you use PHP you can swap this line:</p> <pre><code>&lt;div&gt;Total Parts: &lt;input type="text" id="parts_input" value="1" readonly="true" /&gt;&lt;/div&gt; </code></pre> <p>for one like this:</p> <pre><code>&lt;div&gt;Total Parts: &lt;input type="text" id="parts_input" value="&lt;?PHP include('getTotalParts.php'); ?&gt;" readonly="true" /&gt;&lt;/div&gt; </code></pre> <p>Where the getTotalParts.php is a file you make to get your database information. It can simply grab the information and do a "echo $totalParts;"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload