获取标签以及json字符串拼接

<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal">
     <!--   <form id="form" action="/pressureseting/updatepressureseting" method="post">-->
       <form id="form">
            <div class="nax">
            <table class="table table-bordered" id="dataTable1">
                <tr>
                    <th style="width: 100px;text-align: center">
                        投注类型
                    </th>
                    <th style="width: 80px;text-align: center">
                        退水
                    </th>
                    <th style="width: 80px;text-align: center">
                        单注下限
                    </th>
                    <th style="width: 80px;text-align: center">
                        单注上限
                    </th>
                    <th style="width: 80px;text-align: center">
                        单注限额
                    </th>
                </tr>

                @for(s in item){
                    @if(sLP.index <= 8){
                     <tr>

                        <td id="1">
                            <input type="hidden" name="id" value="${s.id!}"/>
                            ${s.waysPlaying.value!}
                        </td>
                        <td>
                            <input class="active" name="dewater" value="${s.dewater!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">%
                        </td>
                        <td>
                            <input class="active" name="singleFloor" value="${s.singleFloor!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                        </td>
                        <td>
                            <input class="active" name="singleUpper" value="${s.singleUpper!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                        </td>
                        <td>
                            <input class="active" name="singleQuota" value="${s.singleQuota!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                        </td>
                    </tr>
                    @}
                @}
            </table>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                <table class="table table-bordered" id="dataTable2">
                    <tr>
                        <th style="width: 100px;text-align: center">
                            投注类型
                        </th>
                        <th style="width: 80px;text-align: center">
                            退水
                        </th>
                        <th style="width: 80px;text-align: center">
                            单注下限
                        </th>
                        <th style="width: 80px;text-align: center">
                            单注上限
                        </th>
                        <th style="width: 80px;text-align: center">
                            单注限额
                        </th>
                    </tr>

                    @for(s in item){
                    @if(sLP.index > 8){

                    <tr>
                    <td>
                        <input type="hidden" name="id" value="${s.id!}"/>
                        ${s.waysPlaying.value!}
                    </td>
                    <td>
                        <input class="active" name="dewater" value="${s.dewater!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">%
                    </td>
                    <td>
                        <input class="active" name="singleFloor" value="${s.singleFloor!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                    </td>
                    <td>
                        <input class="active" name="singleUpper" value="${s.singleUpper!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                    </td>
                    <td>
                        <input class="active" name="singleQuota" value="${s.singleQuota!}" οnkeyup="value=value.replace(/[^\d\.]/g,'')" οnblur="value=value.replace(/[^\d\.]/g,'')" style="width: 60px;text-align: center">
                    </td>
                    </tr>
                    @}
                    @}
                </table>
            </div>

        </form>

    </div>

         <div class="col-sm-10">
            <#button btnCss="info" name="保存" id="ensure" icon="fa-check" clickFun="PressureSetingInfoDlg.addSubmit()"/>
        </div>
</div>
    <script type="text/javascript">
        function submit() {
            $('.active').attr("style","width:60px;text-align: center;border-color:#f5f5f5");
            var reg = /^[0-9]+([.]{1}[0-9]+){0,1}$/ ; //
            var zhenreg = /^[1-9]\d*$/; // 正整数表达式
            var jsonStr="["
            try {
                $('#dataTable1 tr').each(function (i) {
                    if ($(this).children('td').length > 0) {

                        jsonStr += "{"
                        $(this).children('td').each(function (j) {  // 遍历 tr 的各个 td
                            if ($(this).find("input").val().length > 6){
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "length";
                                return false;
                            }
                            if (!(reg.test($(this).find("input").val()))) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "test";
                                return false;
                            }
                            if ($(this).find("input").attr("name") == 'dewater' && $(this).find("input").val() >100) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw "big";
                                return false;
                            }
                            if (($(this).find("input").attr("name") == 'singleFloor' && !(zhenreg.test($(this).find("input").val()))) || ($(this).find("input").attr("name") == 'singleUpper' && !(zhenreg.test($(this).find("input").val()))) || ($(this).find("input").attr("name") == 'singleQuota' && !(zhenreg.test($(this).find("input").val()))) ) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "zhen";
                                return false;
                            }
                            jsonStr += "\"" + $(this).find("input").attr("name") + "\":" + $(this).find("input").val() + ","

                        });
                        jsonStr = (jsonStr.substring(jsonStr.length - 1) == ',') ? jsonStr.substring(0, jsonStr.length - 1) : jsonStr;
                        jsonStr += "},";
                    }
                });

                $('#dataTable2 tr').each(function (i) {

                    if ($(this).children('td').length > 0) {
                        jsonStr += "{"
                        $(this).children('td').each(function (j) {  // 遍历 tr 的各个 td
                            if ($(this).find("input").val().length > 6){
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "length";
                                return false;
                            }
                            if (!(reg.test($(this).find("input").val()))) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "test";
                                return false;
                            }
                            if ($(this).find("input").attr("name") == 'dewater' && $(this).find("input").val() >100) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw "big";
                                return false;
                            }
                            if (($(this).find("input").attr("name") == 'singleFloor' && !(zhenreg.test($(this).find("input").val()))) || ($(this).find("input").attr("name") == 'singleUpper' && !(zhenreg.test($(this).find("input").val()))) || ($(this).find("input").attr("name") == 'singleQuota' && !(zhenreg.test($(this).find("input").val()))) ) {
                                $(this).find("input").attr("style","width:60px;text-align: center;border-color: red")
                                throw  "zhen";
                                return false;
                            }
                            jsonStr += "\"" + $(this).find("input").attr("name") + "\":" + $(this).find("input").val() + ","
                        });
                        jsonStr = (jsonStr.substring(jsonStr.length - 1) == ',') ? jsonStr.substring(0, jsonStr.length - 1) : jsonStr;
                        jsonStr += "},";
                    }
                });
                jsonStr = (jsonStr.substring(jsonStr.length - 1) == ',') ? jsonStr.substring(0, jsonStr.length - 1) : jsonStr;

                jsonStr += "]"

            }catch (e) {
                if (e.valueOf() == 'length'){
                    Feng.alert("长度不能超过6!");
                }else if (e.valueOf() == 'test') {
                    Feng.alert("请输入正确数据!")
                }else if (e.valueOf() == 'zhen') {
                    Feng.alert("请输入正整数!")
                } else if (e.valueOf() == 'big') {
                    Feng.alert("退水不能超过100%!")
                }
                return;
            }
            $.ajax({
                url:'/pressureseting/updatepressureseting',
                type:'POST',
                data:{"jsonStr":jsonStr},
                dataType:'json',
                success:function(data){
                    if (data.code == 200){
                        PressureSetingInfoDlg.close();
                    }
                }
            });
        }
    </script>

<script src="${ctxPath}/static/modular/games/pressureSeting/pressureSeting_info.js"></script>
    <style type="text/css">
        .nax{
            text-align: center;
            width: 1000px;
            display: flex;
        }
        .nax table{
            width: 500px;
        }
    </style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值