C#MVC DropDown Onchange从视图包中删除下一个下拉列表的选定问题

时间:2018-11-12 16:23:04

标签: javascript asp.net-mvc

我正在尝试构建用户身份问题查看页面。用户选择问题后,我想从列表中删除问题以进行下一个下拉列表,到目前为止,我正在从视图包中选择问题,需要删除选定的问题在下一个下拉框中,任何人都可以提供帮助。

@using (Html.BeginForm())
{
    <div class="loginPanel col-centered" style="width:700px">
        <section id="loginForm">
            <form action="/" class="loginForm" id="form0" method="post" role="form" autocomplete="off">
                <div class="form-horizontal" style="margin-left:auto;margin-right:auto;width:800px">
                    @Html.AntiForgeryToken()
                    <div class="form-horizontal">
                        <hr />
                        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                        <div class="form-group">
                            @Html.LabelFor(model => model.Question1, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.DropDownListFor(model => model.Question1, new SelectList(ViewBag.Questions, "value"), new { id = "Question1",, @class = "form-control", style = "width:500px; overflow:hidden" })

                                @Html.ValidationMessageFor(model => model.Question1)
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Answer1, htmlAttributes: new { @class = "control-label col-md-2", }) })
                            <div class="col-md-10">
                                @Html.TextBoxFor(model => model.Answer1, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Answer1)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.Question2, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.DropDownListFor(model => model.Question2, new SelectList(ViewBag.Questions, "value"), new { id = "Question2", @class = "form-control", style = "width:500px; overflow:hidden" })
                                @Html.ValidationMessageFor(model => model.Question2)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.Answer2, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.TextBoxFor(model => model.Answer2, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Answer2)
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Question3, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.DropDownListFor(model => model.Question3, new SelectList(ViewBag.Questions, "value"), new { id = "Question3", @class = "form-control", style = "width:500px; overflow:hidden" })
                                @Html.ValidationMessageFor(model => model.Question3, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Answer3, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.TextBoxFor(model => model.Answer3, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Answer3, "", new { @class = "text-danger" })
                            </div>
                        </div>
    <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <input type="submit" value="Submit" class="btn btn-lg btn-sharp btn-orange" />
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </section>
    </div>

我知道我需要编写一个JavaScript代码来更新视图包,请问我是MVC的新手,请允许我继续进行操作。

0 个答案:

没有答案