rendered paste body<script> var cillinders = { 2 : { 2: { 'min' : '0', 'max' : '1600', 'price' : '1.2' } , 3: { 'min' : '1601', 'max' : '2000', 'price' : '1.2' } , 4: { 'min' : '2000', 'max' : '0', 'price' : '1.2' } } , 3 : { 5: { 'min' : '0', 'max' : '1600', 'price' : '0.5' } , 6: { 'min' : '1601', 'max' : '2000', 'price' : '0.7' } , 7: { 'min' : '2001', 'max' : '2500', 'price' : '1' } , 8: { 'min' : '2501', 'max' : '3000', 'price' : '1.1' } , 9: { 'min' : '3000', 'max' : '0', 'price' : '1.2' } } , 4 : { 10: { 'min' : '0', 'max' : '1600', 'price' : '0.5' } , 11: { 'min' : '1601', 'max' : '2000', 'price' : '0.7' } , 12: { 'min' : '2001', 'max' : '2500', 'price' : '1' } , 13: { 'min' : '2501', 'max' : '3000', 'price' : '1.1' } , 14: { 'min' : '3000', 'max' : '0', 'price' : '1.2' } } , 5 : { 15: { 'min' : '0', 'max' : '1600', 'price' : '0.35' } , 16: { 'min' : '1601', 'max' : '2000', 'price' : '0.5' } , 17: { 'min' : '2001', 'max' : '2500', 'price' : '0.7' } , 18: { 'min' : '2501', 'max' : '3000', 'price' : '1' } , 19: { 'min' : '3000', 'max' : '0', 'price' : '1.1' } } , 6 : { 20: { 'min' : '0', 'max' : '1600', 'price' : '0.15' } , 21: { 'min' : '1601', 'max' : '2000', 'price' : '0.35' } , 22: { 'min' : '2001', 'max' : '2500', 'price' : '0.5' } , 23: { 'min' : '2501', 'max' : '3000', 'price' : '0.7' } , 24: { 'min' : '3000', 'max' : '0', 'price' : '1' } } } var ages = { '1' : { 'min' : '0', 'max' : '3', 'coef' : '0.5', 'reduction' : '10' } , '2' : { 'min' : '3', 'max' : '6', 'coef' : '1.5', 'reduction' : '20' } , '3' : { 'min' : '6', 'max' : '12', 'coef' : '2', 'reduction' : '30' } , '4' : { 'min' : '12', 'max' : '24', 'coef' : '2.1', 'reduction' : '35' } , '5' : { 'min' : '24', 'max' : '36', 'coef' : '2.2', 'reduction' : '40' } , '6' : { 'min' : '36', 'max' : '48', 'coef' : '2.3', 'reduction' : '42' } , '7' : { 'min' : '48', 'max' : '60', 'coef' : '2.4', 'reduction' : '44' } , '8' : { 'min' : '60', 'max' : '72', 'coef' : '2.5', 'reduction' : '46' } , '9' : { 'min' : '72', 'max' : '84', 'coef' : '2.5', 'reduction' : '48' } , '14' : { 'min' : '84', 'max' : '96', 'coef' : '2.5', 'reduction' : '50' } , '15' : { 'min' : '96', 'max' : '108', 'coef' : '2.5', 'reduction' : '51' } , '12' : { 'min' : '108', 'max' : '120', 'coef' : '2.5', 'reduction' : '52' } , '13' : { 'min' : '120', 'max' : '0', 'coef' : '2.5', 'reduction' : '53' } } function updateFields() { form = document.forms['specialTaxesForm']; polId = form.pollutionId; cmcube = form.cmc; carAge = form.age; cmcubePrice = form.cmcPrice; carAgeCoef = form.coef; carAgeReduction = form.reduction; tax = document.getElementById('specialTax'); if ( cmcube.value.length && !isInt (cmcube.value) ) { cmcube.value = cmcube.value.substring (0, cmcube.value.length - 1); return; } if (!polId.value.length) return; polCillinders = cillinders[polId.value]; theValue = forceNum (cmcube.value); for (i in polCillinders) { if ( (parseInt (theValue) >= parseInt (polCillinders[i]['min']) && parseInt (theValue) <= parseInt (polCillinders[i]['max'])) || (!parseInt (polCillinders[i]['max']) && parseInt (theValue) > parseInt (polCillinders[i]['min'])) ) { price = polCillinders[i]['price']; break; } } try { cmcubePrice.value = price; } catch(e) { cmcubePrice.value = ''; } if (!carAge.value.length) for (i in ages) { carAge.value = i; break; } carAgeCoef.value = ages[carAge.value]['coef']; carAgeReduction.value = ages[carAge.value]['reduction']; tax.innerHTML = parseFloat (forceNum (cmcube.value)) * parseFloat (forceNum (cmcubePrice.value)) * parseFloat (forceNum (carAgeCoef.value)) * (100 - parseFloat (forceNum (carAgeReduction.value))) / 100; } var newCillinders = { 6 : { 20: { 'min' : '0', 'max' : '1600', 'price' : '0.15' } , 21: { 'min' : '1601', 'max' : '2000', 'price' : '0.35' } , 22: { 'min' : '2001', 'max' : '2500', 'price' : '0.5' } , 23: { 'min' : '2501', 'max' : '3000', 'price' : '0.7' } , 24: { 'min' : '3000', 'max' : '0', 'price' : '1' } } , 5 : { 15: { 'min' : '0', 'max' : '1600', 'price' : '0.5' } , 16: { 'min' : '1601', 'max' : '2000', 'price' : '0.6' } , 17: { 'min' : '2001', 'max' : '2500', 'price' : '0.9' } , 18: { 'min' : '2501', 'max' : '3000', 'price' : '1.1' } , 19: { 'min' : '3000', 'max' : '0', 'price' : '1.3' } } , 4 : { 10: { 'min' : '0', 'max' : '1600', 'price' : '1.3' } , 11: { 'min' : '1601', 'max' : '2000', 'price' : '1.4' } , 12: { 'min' : '2001', 'max' : '2500', 'price' : '1.5' } , 13: { 'min' : '2501', 'max' : '3000', 'price' : '1.6' } , 14: { 'min' : '3000', 'max' : '0', 'price' : '1.7' } } , 3 : { 5: { 'min' : '0', 'max' : '1600', 'price' : '1.8' } , 6: { 'min' : '1601', 'max' : '2000', 'price' : '1.8' } , 7: { 'min' : '2001', 'max' : '2500', 'price' : '1.8' } , 8: { 'min' : '2501', 'max' : '3000', 'price' : '1.8' } , 9: { 'min' : '3000', 'max' : '0', 'price' : '1.8' } } , 2 : { 2: { 'min' : '0', 'max' : '1600', 'price' : '2' } , 3: { 'min' : '1601', 'max' : '2000', 'price' : '2' } , 4: { 'min' : '2000', 'max' : '0', 'price' : '2' } } } var newAges = { '1' : { 'min' : '0', 'max' : '3', 'coef' : '0.9', 'reduction' : '15' } , '2' : { 'min' : '3', 'max' : '6', 'coef' : '0.9', 'reduction' : '15' } , '9' : { 'min' : '6', 'max' : '12', 'coef' : '1.8', 'reduction' : '25' } , '3' : { 'min' : '12', 'max' : '24', 'coef' : '1.8', 'reduction' : '25' } , '10' : { 'min' : '24', 'max' : '36', 'coef' : '2.3', 'reduction' : '32' } , '5' : { 'min' : '36', 'max' : '48', 'coef' : '2.3', 'reduction' : '32' } , '11' : { 'min' : '48', 'max' : '60', 'coef' : '2.5', 'reduction' : '43' } , '7' : { 'min' : '60', 'max' : '72', 'coef' : '2.5', 'reduction' : '43' } , '8' : { 'min' : '72', 'max' : '84', 'coef' : '2.7', 'reduction' : '47' } , '12' : { 'min' : '84', 'max' : '96', 'coef' : '2.7', 'reduction' : '47' } , '13' : { 'min' : '96', 'max' : '108', 'coef' : '2.7', 'reduction' : '47' } , '14' : { 'min' : '108', 'max' : '120', 'coef' : '2.7', 'reduction' : '47' } , '15' : { 'min' : '120', 'max' : '0', 'coef' : '2.7', 'reduction' : '47' } } function updateNewFields() { form = document.forms['newSpecialTaxesForm']; newPolId = form.newPollutionId; newCmcube = form.newCmc; newCarAge = form.newAge; newCmcubePrice = form.newCmcPrice; newCarAgeCoef = form.newCoef; newCarAgeReduction = form.newReduction; newTax = document.getElementById('newSpecialTax'); if ( newCmcube.value.length && !isInt (newCmcube.value) ) { newCmcube.value = newCmcube.value.substring (0, newCmcube.value.length - 1); return; } if (!newPolId.selectedIndex) return; newPolCillinders = newCillinders[newPolId.value]; theValue = forceNum (newCmcube.value); for (i in newPolCillinders) { if ( (parseInt (theValue) >= parseInt (newPolCillinders[i]['min']) && parseInt (theValue) <= parseInt (newPolCillinders[i]['max'])) || (!parseInt (newPolCillinders[i]['max']) && parseInt (theValue) > parseInt (newPolCillinders[i]['min'])) ) { price = newPolCillinders[i]['price']; break; } } try { newCmcubePrice.value = price; } catch(e) { newCmcubePrice.value = ''; } if (!newCarAge.selectedIndex) newCarAge.selectedIndex = 1; newCarAgeCoef.value = newAges[newCarAge.value]['coef']; newCarAgeReduction.value = newAges[newCarAge.value]['reduction']; newTax.innerHTML = parseFloat (forceNum (newCmcube.value)) * parseFloat (forceNum (newCmcubePrice.value)) * parseFloat (forceNum (newCarAgeCoef.value)) * (100 - parseFloat (forceNum (newCarAgeReduction.value))) / 100; form = document.forms['specialTaxesForm']; form.pollutionId.selectedIndex = newPolId.selectedIndex; form.cmc.value = newCmcube.value; form.age.selectedIndex = newCarAge.selectedIndex; updateFields (); }</script><style> input.readonly { background-color: #F6F6F6; border: 1px #CECECE solid; } input { border: 1px gray solid; } input, select { width: 150px; } div#specialTax, div#newSpecialTax { color: red; font-weight: bold; border: 1px solid black; width: 150px; height: 20px; }</style><table><tr><td><table cellpadding="0"><tr> <td valign="top" colspan="2"><h1>Taxa speciala pentru prima inmatriculare a automobilelor incepand cu 1 ianuarie 2007, aprobata si publicata in Monitorul Oficial</h1></td></tr></table></td></tr><tr><td><form name="newSpecialTaxesForm"><table width="550" height="300" align="center"><tr> <th>Norme de poluare</th> <td> <select onchange="updateNewFields();" name="newPollutionId"> <option value=""></option> <option value="2">Non-euro</option> <option value="3">Euro1</option> <option value="4">Euro2</option> <option value="5">Euro3</option> <option value="6">Euro4</option> </select> </td></tr><tr> <th>Capacitatea cilindrica</th> <td><input onkeyup="updateNewFields();" type="text" name="newCmc" value="" /> cm<sup>3</sup></td></tr><tr> <th>€ / cm<sup>3</sup></th> <td><input type="text" readonly class="readonly" name="newCmcPrice" value="" /></td></tr><tr> <th>Varsta autoturismului</th> <td> <select onchange="updateNewFields();" name="newAge"> <option value=""></option> <option value="1"><3 luni</option> <option value="2">3 luni - 6 luni</option> <option value="9">6 luni - 1 ani</option> <option value="3">1 ani - 2 ani</option> <option value="10">2 ani - 3 ani</option> <option value="5">3 ani - 4 ani</option> <option value="11">4 ani - 5 ani</option> <option value="7">5 ani - 6 ani</option> <option value="8">6 ani - 7 ani</option> <option value="12">7 ani - 8 ani</option> <option value="13">8 ani - 9 ani</option> <option value="14">9 ani - 10 ani</option> <option value="15">>10 ani</option> </select> luni/ani </td></tr><tr> <th>Coeficient de corelare</th> <td><input type="text" readonly class="readonly" name="newCoef" value="" /></td></tr><tr> <th>Reducere</th> <td><input type="text" readonly class="readonly" name="newReduction" value="" /> %</td></tr><tr> <th>Pret taxa</th> <td> <div id="newSpecialTax"></div> <span style="padding-top:0px;">EURO</td></tr></table></form></td></tr><tr><td><table cellpadding="0"><tr> <td valign="top" colspan="2"><h1>Taxa speciala care nu s-a aprobat si a fost propusa initial</h1></td></tr><tr> <td valign="top" colspan="2" style="font-size:17px;font-weight:bold;"> </td></tr></table></td></tr><tr><td><form name="specialTaxesForm"><table width="550" height="300" align="center"><tr> <th>Norma de poluare</th> <td> <select disabled name="pollutionId"> <option value=""></option> <option value="2">Non-euro</option> <option value="3">Euro1</option> <option value="4">Euro2</option> <option value="5">Euro3</option> <option value="6">Euro4</option> </select> </td></tr><tr> <th>Capacitatea cilindrica</th> <td><input readonly class="readonly" type="text" name="cmc" value="" /> cm<sup>3</sup></td></tr><tr> <th>€ / cm<sup>3</sup></th> <td><input type="text" readonly class="readonly" name="cmcPrice" value="" /></td></tr><tr> <th>Varsta autoturismului</th> <td> <select disabled name="age"> <option value=""></option> <option value="1"><3 luni</option> <option value="2">3 luni - 6 luni</option> <option value="3">6 luni - 1 ani</option> <option value="4">1 ani - 2 ani</option> <option value="5">2 ani - 3 ani</option> <option value="6">3 ani - 4 ani</option> <option value="7">4 ani - 5 ani</option> <option value="8">5 ani - 6 ani</option> <option value="9">6 ani - 7 ani</option> <option value="14">7 ani - 8 ani</option> <option value="15">8 ani - 9 ani</option> <option value="12">9 ani - 10 ani</option> <option value="13">>10 ani</option> </select> luni/ani </td></tr><tr> <th>Coeficient de corelare</th> <td><input type="text" readonly class="readonly" name="coef" value="" /></td></tr><tr> <th>Reducere</th> <td><input type="text" readonly class="readonly" name="reduction" value="" /> %</td></tr><tr> <th>Pret taxa</th> <td> <div id="specialTax"></div> <span style="padding-top:0px;">EURO</td></tr></table></form></td></tr><tr><td><table><tr> <td valign="top"><br /><br /> <span style="font-size:15px;font-weight:bold;color:red">Nota:</span> <span style="font-size:15px;font-weight:bold;color:black">Taxa calculata (afisata) nu contine TVA</span> </td></tr></table></td></tr><tr><td></table> </td> </tr> </table> </td></tr>