Показать сообщение отдельно
  #1 (permalink)  
Старый 03.11.2018, 14:40
Профессор
Отправить личное сообщение для porezon Посмотреть профиль Найти все сообщения от porezon
 
Регистрация: 09.01.2013
Сообщений: 167

подсчет суммы через js
В одном из блоков не работает сколько будет зачислено в долларах.
Не могу понять в чем причина

<article class="uk-panel tp-body uk-article">
<div class="label_l_l">Пополнение баланса на сайте</div>
<div id="payments_money_transfer_wrap" class="payments_money_transfer_wrap">
<form>
<div id="payments_money_transfer_amount_wrap" class="payments_money_transfer_amount_wrap" onclick="elfocus('transfer_amount');">


<div class="row form-box">
<div class="col-lg-6 form-column column1">
<div class="form-fields">

<div class="form-fields__items">
<div class="field-item field-num">
<div class="field-item__input field-num__input">
<input class="payments_money_transfer_amount" type="text" value="35" style="width: 163px;height:100px;" name="amount" id="amount" onfocus="var temp_value=this.value; this.value=''; this.value=temp_value" autofocus/>
<div class="payments_money_transfer_currency"><span class="_short_currency" data-short="RP.">RP</span></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 form-column column3">
<div class="form-fields form-cost">
<div class="form-fields__heading">
<h4>Сумма оплаты составит: <span id="result">3.50</span> $</h4>
</div>
</div>
</div>
</div>

<div id="payments_money_transfer_notice" class="payments_money_transfer_notice">Минимальная сумма пополнения — 35RP.</div>
</div><br />

<div class="uk-form-controls">
<input id="ruserhideemail-1" class="with-gap" type="radio" name="oplata" value="1" checked="checked"> 
<label for="ruserhideemail-1">ADVCASH</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="oplata" value="2"> 
<label for="ruserhideemail-0">PAYEER</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="oplata" value="3"> 
<label for="ruserhideemail-0">Perfect.Money</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="oplata" value="0"> 
<label for="ruserhideemail-0">Bitcoin</label>
</div>
<br />
<div class="uk-text-center"><div class="uk-form-row"><button class="uk-button uk-button-success">Пополнить счет</button></div></div>
<input type="hidden" value="<?=$duser['id'];?>" name="id_p">
<input name="hash" value="<?=myHashData2($iduser);?>" type="hidden">
</form>
</div>
</article>
</div>
<div class="uk-width-medium-2-5">
<article class="uk-panel tp-body uk-article">
<div class="label_l_l">Вывести средства</div>
<div id="payments_money_transfer_wrap" class="payments_money_transfer_wrap">
<form>
<div id="payments_money_transfer_amount_wrap" class="payments_money_transfer_amount_wrap" onclick="elfocus('transfer_amount');">
<div class="row form-box">
<div class="col-lg-6 form-column column1">
<div class="form-fields">

<div class="form-fields__items">
<div class="field-item field-num">
<div class="field-item__input field-num__input">
<input class="payments_money_transfer_amount t2" type="text" value="10" style="width: 163px;height:100px;" name="amouns" id="amouns" onfocus="var temp_value=this.value; this.value=''; this.value=temp_value" autofocus/>
<div class="payments_money_transfer_currency"><span class="_short_currency" data-short="RP.">RP</span></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 form-column column3">
<div class="form-fields form-cost">
<div class="form-fields__heading">
<h4>Будет зачислено на кошелек: $<span id="cresult">1</span></h4>
</div>
</div>
</div>
</div>

<div id="payments_money_transfer_notice" class="payments_money_transfer_notice">Минимальная сумма вывода — 100RP.</div>
</div><br />

<div class="uk-form-controls">
<input id="ruserhideemail-1" class="with-gap" type="radio" name="ruserhideemail" value="1" checked="checked"> 
<label for="ruserhideemail-1"> AdvCASh</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="ruserhideemail" value="0"> 
<label for="ruserhideemail-0">Payeer</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="ruserhideemail" value="0"> 
<label for="ruserhideemail-0">Perfect.Money</label>
<input id="ruserhideemail-0" class="with-gap" type="radio" name="ruserhideemail" value="0"> 
<label for="ruserhideemail-0">Bitcoin</label>
</div>
<br />
<div class="uk-text-center"> <div class="uk-form-row"><button class="uk-button uk-button-info">Вывести средства</button> </div> </div>
</form>
</div>

</article>


<script type="text/javascript">
            function number_format(number, decimals, dec_point, thousands_sep) {
                var i, j, kw, kd, km;
                if (isNaN(decimals = Math.abs(decimals))) { decimals = 2; }
                if (dec_point == undefined) { dec_point = ","; }
                if (thousands_sep == undefined) { thousands_sep = "."; }
                i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
                if ((j = i.length) > 3) { j = j % 3; } else { j = 0; }
                km = (j ? i.substr(0, j) + thousands_sep : "");
                kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
                kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
                return km + kw + kd;
            }
    
window.onload=function(){
function init() {
var cblocks = document.getElementById('amount');
var result = document.getElementById('result');  
var blockPrice = 0.1;
function updatePrice() {
result.innerHTML = number_format(cblocks.value * blockPrice, 2, '.', '');
}
cblocks.addEventListener( 'input', updatePrice );
cresol.addEventListener( 'input', updatePrice );
}
init();
}

window.onload=function(){
function initz() {
var cblocks = document.getElementById('amouns');
var result = document.getElementById('result');  
var blockPrice = 0.1;
function updatePrice() {
cresult.innerHTML = number_format(cblocks.value * blockPrice, 2, '.', '');
}
cblocks.addEventListener( 'input', updatePrice );
cresol.addEventListener( 'input', updatePrice );
}
initz();
}
</script>
Ответить с цитированием