skip to Main Content
0049-89-49053501 support@wptools.de

How to update a html table column from neighbour column using java script?

Starting 2015 customers from other EU countries must be charged their home VAT rate. (This does not apply to companies which can provide a VAT ID – in their case no VAT is charged)

Since it is legally demanded to show the prices including the VAT, the problem was:

How to update a price in a html table column using java script?

Probably other developers have to deal with the update of html table in java script so here is my solution.

The code operates on a html table with the id “ordertable” – in this simple example with only 3 columns:

Name Price Price incl. x% VAT
Product A 100 ?
Product B 250 ?

A combobox is required to select the VAT rate – the assigned “value” for each entry is the VAT rate.

This is the code which performs the update of the table above:

I collected the VAT rates of the EU countries while working on the WPTools MultiDemo.
An official source for the rates is the link below – the values in the demo may be outdated or incorrect.
http://ec.europa.eu/taxation_customs/taxation/vat/how_vat_works/rates/index_en.htm.

Back To Top