-1
if else
固定値の条件で比較した後にエラーメッセージを表示するjQueryコードテーブルがありますが、動作しません。if else
の条件にテーブル入力型の値が必要です。他の条件がテーブル入力フィールドの場合
誰でも確認できますか?&私は間違っていることを教えてください。ありがとうございました。
<script type="text/javascript">
$(function() {
$('.pnm, .price, .subtot, .widtot, .perm, .tottot, .vol, .tot, .vols, .widths, .depths, .heights, .acts, .heitot').prop('readonly', true);
var $tblrows = $("#tblProducts tbody tr");
$tblrows.each(function (index) {
var $tblrow = $(this);
$tblrow.find('.width, .carton, .depth, .height, .act, .tot, .vol, .perm').on('change', function() {
var height = $tblrow.find("[name=height][type=number][min=0]").val();
var subCalc = parseFloat(height);
if (!isNaN(subCalc)) {
$tblrow.find('.calcheight').val(subCalc.toFixed(5));
var calcTotal = 0;
$(".calcheight").each(function() {
var stval = parseFloat($(this).val());
calcTotal += isNaN(stval) ? 0 : stval;
});
$('.heitot').val(calcTotal.toFixed(5));
}
});
});
});
</script>
<table id="tblProducts">
<script type="text/javascript">
var sp = $('#sellingprice').val() | 0;
if (sp >= 2.38) {
<?php echo "error with 20 STD and error with 40 STD"; ?>
}
else if (sp >= 2.69){
<?php echo "error with 40 HC"; ?>
}
else
{
<?php echo ""; ?>
}
</script>
<tbody>
<tr>
<td><input type="text" class="pnm" value="First One" name="pnm" style="width:120px" /></td>
<td><input type="number" oninput="validity.valid||(value='');" id="sellingprice" class="height" value="0" name="height" min="0" maxlength="5" style="width:100px"/></td>
<td><input type="number" class="calcheight" value="" name="calcheight" style="width:100px" readonly/></td>
</tr>
<tr>
<td><input type="text" class="pnm" value="Second One" name="pnm" style="width:120px" /></td>
<td><input type="number" oninput="validity.valid||(value='');" id="sellingprice" class="height" value="0" name="height" min="0" maxlength="5" style="width:100px"/></td>
<td><input type="number" class="calcheight" value="" name="calcheight" style="width:100px" readonly/></td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td><input type="number" class="heitot" value="" name="" style="width:100px" readonly/></td>
</tr>
</tfoot>
</table>
しかし、私がするvar SP = $( '#のsellingprice')の代わりに使用しなければならないのval()|。 0; – user7428613
あなたは何を変更すべきかを示す答えを更新しました。 – Scovetta
私はあなたが私に提案した変更を行いましたが、うまく動作しませんでした。それは私に何かエラーメッセージが表示されないことを再度確認してくださいよろしくお願いします。Inder - – user7428613