Javascript 如何使用mvc从表单查看表中的数据

Javascript 如何使用mvc从表单查看表中的数据,javascript,asp.net-mvc,asp.net-mvc-4,Javascript,Asp.net Mvc,Asp.net Mvc 4,在表单中输入所有详细信息后。当我在“药品总量”字段中单击“输入”时。所有字段应显示在下表中,然后我在表单中输入第二个详细信息的详细信息,然后所有字段数据应显示在第二行,就像我需要填写表格一样。最后,我单击“保存”按钮,它应将所有表数据保存在数据库中。我在网上搜索了一下,但没有找到任何参考代码 @using (Html.BeginForm("PrescriptionManagement", "Prescription", FormMethod.Post, new { id = "myForm"

在表单中输入所有详细信息后。当我在“药品总量”字段中单击“输入”时。所有字段应显示在下表中,然后我在表单中输入第二个详细信息的详细信息,然后所有字段数据应显示在第二行,就像我需要填写表格一样。最后,我单击“保存”按钮,它应将所有表数据保存在数据库中。我在网上搜索了一下,但没有找到任何参考代码

 @using (Html.BeginForm("PrescriptionManagement", "Prescription", FormMethod.Post, new { id = "myForm" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)
            <section class="card">
                <div class="card-block">
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Prescription Date</label>
                                <div class='input-group date'>
                                    <input id="PrescriptionDate" name="PrescriptionDate" type="text" value=@DateTime.Now.ToString("dd/MM/yyyy") class="form-control" style="border-width: 0 0 2px 0;">
                                    <span class="input-group-addon">
                                        <i class="font-icon font-icon-calend"></i>
                                    </span>
                                    @Html.ValidationMessageFor(model => Model.prescriptionmanagement.PrescriptionDate, null, new { @style = "color: red" })
                                </div>
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Doctor Name</label>
                                @Html.DropDownList("DoctorID", null, "--- Select Doctor Name ---", new { @class = "select2-arrow" })
                                @Html.ValidationMessageFor(model => Model.prescriptionmanagement.DoctorID, null, new { @style = "color: red" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Patient Name</label>
                                @Html.DropDownList("PatientID", null, "--- Select Doctor Name ---", new { @class = "select2-arrow" })
                                @Html.ValidationMessageFor(model => Model.prescriptionmanagement.PatientID, null, new { @style = "color: red" })
                            </fieldset>
                        </div>
                    </div><br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Age</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Age, new { @class = "form-control", @id = "txtAge", placeholder = "Age" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Diagnosis</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Diagnosis, new { @class = "form-control", @id = "txtDiagnosis", placeholder = "Diagnosis" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Gender</label>
                                <br />
                                <div class="form-group form-group-radios">
                                    <div class="radio">
                                        @Html.RadioButtonFor(model => model.prescriptionmanagement.Gender, "Male", new { @name = "optionsRadios", @class = "form-control", @id = "radio-1" })
                                        <label for="radio-1">Male </label>
                                        &nbsp; &nbsp;&nbsp; &nbsp;
                                        @Html.RadioButtonFor(model => model.prescriptionmanagement.Gender, "Female", new { @name = "optionsRadios", @class = "form-control", @id = "radio-2" })
                                        <label for="radio-2">Female</label>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Weight</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Weight, new { @class = "form-control", @id = "txtWeight", placeholder = "Weight" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Temperature</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Temperature, new { @class = "form-control", @id = "txtTemperature", placeholder = "Temperature" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Blood Sugar</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.BloodSugar, new { @class = "form-control", @id = "txtBloodSugar", placeholder = "BloodSugar" })
                            </fieldset>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Blood Pressure</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.BloodPressure, new { @class = "form-control", @id = "txtBloodPressure", placeholder = "BloodPressure" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">MedicineName</label>
                                @*@Html.TextBoxFor(model => Model.MedicineName, new { @class = "form-control", @id = "txtMedicineName", placeholder = "MedicineName" })*@
                                <div class="typeahead-container">
                                    <div class="typeahead-field">
                                        <span class="typeahead-query">
                                            @Html.TextBoxFor(model => Model.prescriptionmanagement.MedicineName, new { @class = "form-control", @id = "txtMedicineName", placeholder = "Medicine Name", name = "d", type = "search", autocomplete = "off" })
                                            <input type="hidden" id="hfCustomer" name="CustomerId" />
                                        </span>
                                    </div>
                                </div>
                                @Html.ValidationMessageFor(model => Model.prescriptionmanagement.MedicineName, null, new { @style = "color: red" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Drug Specifications</label>
                                <div class="tbl-cell tbl-cell-action button">
                                    <a href="#" data-toggle="modal" id="btnClick" data-target="#upload3Modal" class="btn btn-rounded btn-block">Drug Specifications&nbsp;&nbsp;<span class="font-icon-search"></span></a>
                                </div>
                            </fieldset>
                        </div>
                    </div><br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Days</label>
                                <input id="demo3" type="text" value="1" name="demo3" />
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Morning</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Morning, new { @Value = "0", @class = "form-control", @id = "txtMorning", placeholder = "Morning" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Afternoon</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Afternoon, new { @Value = "0", @class = "form-control", @id = "txtAfternoon", placeholder = "Morning" })
                            </fieldset>
                        </div>
                    </div><br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Evening</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Evening, new { @Value = "0", @class = "form-control", @id = "txtEvening", placeholder = "Morning" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Night</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Night, new { @Value = "0", @class = "form-control", @id = "txtNight", placeholder = "Morning" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">BF / AF</label>
                                <select class="select2-arrow" id="BFAF" name="Status">
                                    <option>--- Select BF / AF ---</option>
                                    <option value="AF">AF</option>
                                    <option value="BF">BF</option>
                                </select>
                            </fieldset>
                        </div>
                    </div><br />
                    <div class="row">
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">Dose / Ml</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.Dose, new { @Value = "0", @class = "form-control", @id = "txtDoseMl", placeholder = "Dose / Ml" })
                            </fieldset>
                        </div>
                        <div class="col-lg-4">
                            <fieldset class="form-group">
                                <label class="form-label" for="exampleInput">TotalMedications</label>
                                @Html.TextBoxFor(model => Model.prescriptionmanagement.TotalMedications, new { @class = "form-control", @id = "txtTotalMedications", placeholder = "Total Medications" })
                                @Html.ValidationMessageFor(model => Model.prescriptionmanagement.TotalMedications, null, new { @style = "color: red" })
                             </fieldset>
                        </div>
                    </div>
                    <input type="submit" name="actionType" value="Save" class="btn btn-rounded btn-inline btn-success" />
                    <br /><br />
                    <span class="label label-success">@ViewBag.Message</span>
                </div>
            </section>
            <!-- Start Model Pop Up-->
            <div class="modal fade" id="upload3Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="modal-close" data-dismiss="modal" aria-label="Close">
                                <i class="font-icon-close-2"></i>
                            </button>
                            <h4 class="modal-title" id="myModalLabel">Drug Specifications</h4>
                        </div>
                        <div class="modal-upload menu-big-icons">
                            <div class="modal-upload-cont">
                                <div class="modal-upload-cont-in" style="border-left: none;">
                                    <div class="tab-content">
                                        <div role="tabpanel" class="tab-pane active" id="tab-upload-3-1">
                                            <br />
                                            <div class="row">
                                                <div class="col-lg-4">
                                                    <fieldset class="form-group">
                                                        <label class="form-label" for="exampleInput">Generic Name</label>
                                                        @Html.TextBoxFor(model => Model.productmaster.GenericName, new { @class = "form-control", @id = "txtGenericName", placeholder = "Generic Name" })
                                                        @*@Html.Hidden("GenericID", null, new { @id = "hdnGenericID" })*@
                                                        <input type="hidden" id="hdnGenericID" name="GenericID" />
                                                    </fieldset>
                                                </div>
                                            </div>
                                        </div><!--.tab-pane-->
                                    </div><!--.tab-content-->
                                </div><!--.modal-upload-cont-in-->
                            </div><!--.modal-upload-cont-->
                        </div>
                    </div>
                </div>
            </div><!--.modal-->
            <!-- End Model Pop Up-->
        }
@使用(Html.BeginForm(“处方管理”,“处方”,FormMethod.Post,new{id=“myForm”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
处方日期
@Html.ValidationMessageFor(model=>model.prescriptionmanagement.PrescriptionDate,null,新{@style=“color:red”})
医生姓名
@DropDownList(“DoctorID”,null,“--Select Doctor Name--”,new{@class=“select2 arrow”})
@Html.ValidationMessageFor(model=>model.prescriptionmanagement.DoctorID,null,新{@style=“color:red”})
患者姓名
@DropDownList(“PatientID”,null,“--Select Doctor Name--”,new{@class=“select2 arrow”})
@Html.ValidationMessageFor(model=>model.prescriptionmanagement.PatientID,null,新{@style=“color:red”})

年龄 @Html.TextBoxFor(model=>model.prescriptionmanagement.Age,新的{@class=“form control”,@id=“txtAge”,placeholder=“Age”}) 诊断 @Html.TextBoxFor(model=>model.prescriptionmanagement.Diagnosis,新的{@class=“form control”,@id=“txtDiagnosis”,placeholder=“Diagnosis”}) 性别
@Html.radioButton(model=>model.prescriptionmanagement.Gender,“男性”,新的{@name=“optionsRadios”,@class=“form control”,@id=“radio-1”}) 男性的 @Html.radioButton(model=>model.prescriptionmanagement.Gender,“女性”,新的{@name=“optionsRadios”,@class=“form control”,@id=“radio-2”}) 女的
重量 @Html.TextBoxFor(model=>model.prescriptionmanagement.Weight,新的{@class=“form control”,@id=“txtwweight”,placeholder=“Weight”}) 温度 @Html.TextBoxFor(model=>model.prescriptionmanagement.Temperature,新的{@class=“form control”,@id=“txtdemperature”,placeholder=“Temperature”}) 血糖 @Html.TextBoxFor(model=>model.prescriptionmanagement.BloodSugar,新的{@class=“form control”,@id=“txtBloodSugar”,placeholder=“BloodSugar”})
血压 @Html.TextBoxFor(model=>model.prescriptionmanagement.BloodPressure,新的{@class=“form control”,@id=“txtbodpressure”,placeholder=“BloodPressure”}) 药名 @*@Html.TextBoxFor(model=>model.MedicineName,新的{@class=“form control”,@id=“txtMedicineName”,placeholder=“MedicineName”})*@ @Html.TextBoxFor(model=>model.prescriptionmanagement.MedicineName,新的{@class=“form control”,@id=“txtMedicineName”,placeholder=“mediciname”,Name=“d”,type=“search”,autocomplete=“off”}) @Html.ValidationMessageFor(model=>model.prescr
<script>
    function UpdateForm(arg) {
      $.ajax({
        url: '@Url.Action("yourMethod", "yourController")',
        type: "GET",
        data: { arg1: arg1 },
        success: (function (result) {
        $("#yourDiv").html(result);
      });
    }
</script>
<div id="yourDiv">
  @Html.Partial("~/Views/yourController/yourPartialView.cshtml", yourModel)
</div>
@model yourNamespace.yourViewModel
<form>
  @Html.EditorFor(model => model)
  <div>
    <fieldset>
        <legend>A legend</legend>
        @Html.CheckBoxFor(model => model.field1)
        @Html.EditorFor(model => model.field2, new { htmlAttributes = new { @class = "form-control" } })
            <!-- etc... -->
    </fieldset>
  </div>
</form>
public class yourController : Controller
{
    public ActionResult yourMethod(object arg1)
    {
        //Get data from database here
        return PartialView("yourView", yourModel);
    }
}
<script>
  $('#yourDiv').load('@Url.Action("yourMethod", "yourController")', { arg1 : arg1 });
</script>