在我的网站表单中,我需要将var kwh_production
连接到选择框项的值相乘。这是我的代码,但不起作用,因为它不检查所选项目,只是乘以kwh_production
最后一个值(0.27325)
function earn_or_save() {
var eos = 0;
// erd modules
if ($('select_20').val() = 3025) eos = kwh_production * 0.28525
if ($('select_20').val() = 4407) eos = kwh_production * 0.28525
if ($('select_20').val() = 5809) eos = kwh_production * 0.28525
if ($('select_20').val() = 5850) eos = kwh_production * 0.27325
if ($('select_20').val() = 8724) eos = kwh_production * 0.27325
if ($('select_20').val() = 9320) eos = kwh_production * 0.27325
if ($('select_20').val() = 10464) eos = kwh_production * 0.27325
if ($('select_20').val() = 13649) eos = kwh_production * 0.27325
if ($('select_20').val() = 15938) eos = kwh_production * 0.27325
if ($('select_20').val() = 16326) eos = kwh_production * 0.27325
if ($('select_20').val() = 17612) eos = kwh_production * 0.27325
if ($('select_20').val() = 21288) eos = kwh_production * 0.27325
// europe modules
if ($('select_20').val() = 3289) eos = kwh_production * 0.28525
if ($('select_20').val() = 4882) eos = kwh_production * 0.28525
if ($('select_20').val() = 6410) eos = kwh_production * 0.28525
if ($('select_20').val() = 9350) eos = kwh_production * 0.27325
if ($('select_20').val() = 9350) eos = kwh_production * 0.27325
if ($('select_20').val() = 10481) eos = kwh_production * 0.27325
if ($('select_20').val() = 11463) eos = kwh_production * 0.27325
if ($('select_20').val() = 14745) eos = kwh_production * 0.27325
if ($('select_20').val() = 17269) eos = kwh_production * 0.27325
if ($('select_20').val() = 18285) eos = kwh_production * 0.27325
if ($('select_20').val() = 19772) eos = kwh_production * 0.27325
if ($('select_20').val() = 23653) eos = kwh_production * 0.27325
if (eos != 0) {
$("earn_or_save").set('text', "€ " + number_format(eos, 2, ',', '.'));
$("i_earn_or_save").value = number_format(eos, 2, '.', '');
}
else {
$("earn_or_save").set('text', "");
$("i_earn_or_save").value = 0;
}
}
$("select_20").addEvent('onChange', earn_or_save);