代码改变世界

H5 拼接动态ID

2019-08-01 14:24  石吴玉  阅读(640)  评论(0编辑  收藏  举报
<form class="m-form m-form--state m-form--fit m-form--label-align-right m-form--group-seperator-dashed" id="m_form">
                    @{
                        int i = 0;
                        foreach (var item in ViewBag.PorpList)
                        {
                            i++;
                            <div class="m-portlet__body">
                                <div class="form-group m-form__group row">
                                    <label class="col-lg-2 col-form-label">
                                        <font style="vertical-align: inherit;">
                                            <font style="vertical-align: inherit;">
                                                类型:
                                            </font>
                                        </font>
                                    </label>
                                    <div class="col-lg-3 m-form__group-sub">
                                        <div class="m-form__control">
                                            @Html.DropDownList("PropType" + i, ViewBag.ProTypeList as IEnumerable<SelectListItem>, new { @class = "form-control m-bootstrap-select" })
                                            <script>
                                                $(function () {
                                                    $(@Html.Raw("\"#PropType" + i + "\"")).attr('value',@item.PropType)
                                                });
                                            </script>
                                        </div>
                                    </div>
                                    <label class="col-lg-2 col-form-label">
                                        <font style="vertical-align: inherit;">
                                            <font style="vertical-align: inherit;">
                                                数量:
                                            </font>
                                        </font>
                                    </label>
                                    <div class="col-lg-3 m-form__group-sub">
                                        <input class="form-control m-input m-input--pill" data-val="true" data-val-number="字段 PropAmount 必须是一个数字。" data-val-required="PropAmount 字段是必需的。" @Html.Raw("id=\"PropAmount" + i + "\"") name="PropAmount" placeholder="请输入奖品数量" type="text" value="@item.PropAmount">
                                    </div>
                                </div>
                            </div>
                        }
                    }
                    @*保存*@
                    <div class="m-portlet__foot m-portlet__no-border m-portlet__foot--fit">
                        <div class="m-form__actions m-form__actions--solid">
                            <div class="row">
                                <div class="col-lg-2"></div>
                                <div class="col-lg-10">
                                    <button class="btn m-btn--pill m-btn--air btn-success m-btn--wide" id="btnSave">
                                        <font style="vertical-align: inherit;">
                                            <font style="vertical-align: inherit;">
                                                保存
                                            </font>
                                        </font>
                                    </button>
                                    <button type="button" class="btn m-btn--pill m-btn--air btn-secondary m-btn--wide" id="btnReturn">
                                        <font style="vertical-align: inherit;">
                                            <font style="vertical-align: inherit;">
                                                取消
                                            </font>
                                        </font>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>