I wrote the converter of values but for some reason it does not calculate and displays "0" everywhere, tell me why? If it doesn't make it difficult for you write a piece js to output the result (
<html> <head> <meta charset="utf-8"> <head/> <body> <form> <label>Enter a value</label> <select name="from" id="from"> <option value="0" selected="selected">Killometres</option> <option value="1">Milles</option> <option value="2">Futs</option> <option value="2">Yards</option> <option value="2">Dums</option> </select> <br/> <br/> <label>Enter a count </label> <input name="cash" id="cash" class="is" type="text"/> <br/> <br/> <label>Enter a change value </label> <select name="to" id="to"> <option value="0" >Killometres</option> <option value="1"selected="selected">Milles</option> <option value="2">Futs</option> <option value="3">Yards</option> <option value="4">Dums</option> </select> <br/> <br/> <input type=button value="Convert" onclick='GiveResult();'> <br/> <br/> <label><span id="result" class="result"></span></label> </form> <script type="text/javascript"> c = new Array(); n = new Array(); c[0] = 1; n[0] = "Killometres"; c[1] = 0,62; n[1] = "Milles"; c[2] = 4; n[2] = "Futs"; c[3] = 5; n[3] = "Yards"; c[4] = 6; n[4] = "Dums"; function GiveResult() { var res, vfrom, vto, vcash; vcash = document.getElementById("cash").value; vfrom = document.getElementById("from").value; vcash = vcash.replace(',', '\.'); vcash = vcash.replace(' ', ''); vcash = vcash.replace(' ', ''); vto = document.getElementById("to").value; res = c[vto] * vcash / c[vfrom], 2; res = res.toFixed(0); res = res.toString(); res = res.replace('\.', ','); res = "<span class='result'> Результат перевода: " + res + "</span> " + n[vto]; document.getElementById("result").innerHTML = res; } </script> </body> </html>
c[1] = 0,62;andc[vfrom], 2? - Grundy