テキストフィールドの結果を計算しようとしています。私は2つのテキストフィールドがあり、誰かが最初のテキストフィールドに3 or 4
のような値を入力すると、2番目のtextfield.Iの結果を生成します。もし誰かが2番目の値を入力しようとすると、私のコードは以下の通りです。私の2番目のテキストフィールドは私に値を変更させません。jsを使用してテキストフィールドを相互に計算する
<script type="text/javascript">
jQuery(function(jQuery) {
jQuery('.product-custom-option').on('keyup', function() {
var total = jQuery('.product-custom-option').val();
var perunit = 3;
var newprice = total/perunit;
jQuery('#no_packs').val(Math.ceil(newprice));
});
});
jQuery(function(jQuery) {
jQuery('#no_packs').on('keyup', function() {
var total = jQuery('#no_packs').val();
var perunit = 3;
var newprice = total * perunit;
jQuery('.product-custom-option').val(newprice);
});
});
</script>
HTML:
<dl class="last">
<dt>
</dt><dt><label class="required"><em>*</em>Square meters required</label>
</dt>
<dd class="last">
<div class="input-box">
<input type="text" onchange="opConfig.reloadPrice()" id="options_134_text" class="input-text required-entry product-custom-option" name="options[134]" value="">
</div>
</dd>
</dl>
<div class="">
<label class="required">Number of Packs</label>
<div class="input-box">
<input type="text" id="no_packs" class="input-text product-custom-option" name="qty" value="">
</div>
</div>
あまりにも 'html'を投稿してください。デモスナップを追加するとクールになりますペット.. –
'opConfig.reloadPrice()'とは何ですか? – BenG
入力値 –