Сообщение от Dilettante_Pro
|
Возвращаясь к самому началу темы....
<div>
Период <select id="period">
<option value = "25">25</option>
<option value = "20">20</option>
<option value = "15">15</option>
<option value = "10">10</option>
</select>
<br>
Сумма депозита <input type="text" id="deposit" class = "onlyDigits" value="10"/><br>
<input type="button" onclick="summ();" value="Расчет" >
</div>
<div id="debet" ></div>
<div id="summa"></div>
<script>
var debet= [{percent: 2, period: 25, min: 10, max:500},{percent: 3.3, period: 20, min: 510, max:5000},{percent: 4.5, period: 15, min: 5010, max:10000},{percent: 6.3, period: 10, min: 10010, max:100000}],
minDebet = 10,
maxDebet = 500,
percent = 2;
function onlyDigits() {
this.value = this.value.replace(/[^\d]/g, "");
document.querySelector("#debet").innerHTML = " ";
document.querySelector("#summa").innerHTML = "";
}
document.querySelector(".onlyDigits").oninput = onlyDigits;
function summ() {
var dep = document.querySelector('#deposit'),
depv = +dep.value;
if(depv < minDebet) dep.value = minDebet.toString();
if(depv > maxDebet) dep.value = maxDebet.toString();
depv = +dep.value;
var period = document.querySelector("#period").value;
var result = (depv * percent * period / 100);
document.querySelector("#debet").innerHTML = "Доход: " + result;
document.querySelector("#summa").innerHTML = "Итого: " + (result + depv);
}
document.querySelector("#period").onchange = function() {
var period = +this.value;
for(var i = 0; i < debet.length; i++) {
if(debet[i].period == period) {
minDebet = debet[i].min;
maxDebet = debet[i].max;
percent = debet[i].percent;
document.querySelector("#deposit").value = minDebet.toString();
document.querySelector("#debet").innerHTML = " ";
document.querySelector("#summa").innerHTML = "";
}
}
}
</script>
|
Это какое то горе) ставлю код на сайт на стрничку.
и выдает вот такое
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "tpl/ru/udp/adv.tpl" on line 35 "var debet= [{percent: 2, period: 25, min: 10, max:500},{percent: 3.3, period: 20, min: 510, max:5000},{percent: 4.5, period: 15, min: 5010, max:10000},{percent: 6.3, period: 10, min: 10010, max:100000}]," - Unexpected ": ", expected one of: "}" , " "' in /home/spiri660/public_html/tehno-world.com/smarty3/sysplugins/smarty_internal_templatecompilerbase.php:627 Stack trace: #0 /home/spiri660/public_html/tehno-world.com/smarty3/sysplugins/smarty_internal_templateparser.php(3154): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 /home/spiri660/public_html/tehno-world.com/smarty3/sysplugins/smarty_internal_templateparser.php(3219): Smarty_Internal_Templateparser->yy_syntax_error(2, ': ') #2 /home/spiri660/public_html/tehno-world.com/smarty3/sysplugins/smarty_internal_smartytemplatecompiler.php(105): Smarty_Internal_Templateparser->doParse(2, ': ') #3 /home/spiri660/public_html/teh in /home/spiri660/public_html/tehno-world.com/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 627