自定义选择器、存数值

//deom1
//date-name="Property_QtyFail" 
//自定义选择器(名称随便)="选择器值"
<input name="QtyFail" date-name="Property_QtyFail" onchange="changeBadNumber(this)" class="inputbox" style="width:50px;" value="@(inspectionDetail.BadQty)" disabled />

//JS
var inupt_QtyFail = $("input[date-name='Property_QtyFail']");//不良数
inupt_QtyFail[0].value;
function changeBadNumber(that) {
        var value = $(that).val();
        if (value == "") {
            return false;
        }
        //刷新合格数  SamplingSize  QualifiedNumber
        var badAcceptanceQty = parseInt($(that).parent().parent().find("td[name='BadAcceptance']").text());
        var badRejectionQty = parseInt($(that).parent().parent().find("td[name='BadRejection']").text());
        var inspectionQty = $(that).parent().parent().find("td[name='SamplingSize']").text();

        var qualifiedQty = parseInt(inspectionQty) - parseInt(value);
        if (qualifiedQty < 0) {
            $(that).parent().parent().find("td[name='QualifiedQty']").find('input').val('0');
        }
        else {
            $(that).parent().parent().find("td[name='QualifiedQty']").find('input').val(qualifiedQty);
        }

        if (value <= badAcceptanceQty) {
            $(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').val('@Html.Raw(Label.Pass)');
            $(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').change();
        }
        else {
            $(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').val('@Html.Raw(Label.Failure)');
            $(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').change();
        }
    }
//deom2
//data-type定义选择器 ;data存值
//data-type="GroupAttr" data="@(inspectionDetail.GroupAttr)"
<input id="txt" data-type="GroupAttr" data="@(inspectionDetail.GroupAttr)" name="@inspectionDetail.GroupName" CodeName="@detail.InspectionItems.CodeName" iscollect="N" value="@(inspectionCollectionDetail.Count == 0 ? " " : inspectionCollectionDetail.First().InspectionValue)" UpperLimit="@detail.InspectionItems.UpperLimit" LowerLimit="@detail.InspectionItems.LowerLimit" class="inputbox" inspectionOrder="@inspectionDetail.SortOrder" itemOrder="@detail.SortOrder" eachCollection="@detail.InspectionItems.EachCollection" onblur="calAnalysis(this)" />

//JS
 function calAnalysis(that) {
        //性能测试项
        var GroupAttrType = $(that).parent().find("input[data-type='GroupAttr']").attr('data');
        if ($(that).val() == "" || GroupAttrType=="@(Const.PERFORMANCEL_INSPECTION)")
        {
            return;
        }
        var inspectionName = $(that).attr("CodeName");
        var enterValue = parseFloat($(that).val());
        var upperValue = parseFloat($(that).parent().find("i[name='upperLimit']").text());
        var lowerValue = parseFloat($(that).parent().find("i[name='lowerLimit']").text());
        //检测输入的值
       if (enterValue != NaN && enterValue != undefined&&(enterValue > upperValue || enterValue < lowerValue)){
            $(that).css('color', 'red');
        }
       else if (enterValue != NaN && enterValue != undefined && (lowerValue<= enterValue <= upperValue)) {
           $(that).css('color', '');
       }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值