Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
How to insert <span> value into database

I have HTML tables with "span data-prefix" in each one witch is an calculation of a quote page, i want to insert that value into my database, every thing i try messes with the calculation in some way or wont work at all, can i use id to call the value or javascript, maybe im just missing something can someone assist me please.

// get balance cells

for (var a = document.querySelectorAll('table.balance tbody tr'), i = 0; a[i]; ++i) {

  cells = document.querySelectorAll('table.balance td:last-child span:last-child');

  // Calculate Discount (Subtotal - Discount)
  totalDiscount = price - parseFloatHTML(cells[0]);

  // Calculate VAT (Total less discount * VAT)
  vat = parseFloatHTML(cells[1]) * 0.15;

  //Calculate Total (Total Less Discount + VAT)
  totalBalance = parseFloatHTML(cells[1]) + parseFloatHTML(cells[3]);

  // set total

  cells[1].innerHTML = totalDiscount;
  cells[3].innerHTML = vat;
  cells[4].innerHTML = totalBalance;
  cells[5].innerHTML = totalBalance;

}

// update prefix formatting

var prefix = document.querySelector('#prefix').innerHTML;
for (a = document.querySelectorAll('[data-prefix]'), i = 0; a[i]; ++i) a[i].innerHTML = prefix;

// update price formatting

for (a = document.querySelectorAll('span[data-prefix] + span'), i = 0; a[i]; ++i)
  if (document.activeElement != a[i]) a[i].innerHTML = parsePrice(parseFloatHTML(a[i]));
<table class="balance">
  <tr>
    <th>
      <h2>VAT Total</h2>
    </th>
    <td>
      <span name="vat" data-prefix>R</span><span></span>
    </td>
  </tr>
  <tr>
    <th>
      <h2>Total</h2>
    </th>
    <td>
      <span name="total_after_tax" data-prefix>R</span><span></span>
    </td>
  </tr>
</table>

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!