根据下拉列表的更改在文本框中显示值

时间:2012-11-27 02:02:41

标签: jquery asp.net-mvc

我有一个部分视图,有一个下拉列表和更改下拉列表,我需要更新相应文本框中的值,但值不显示evn虽然值存在。请帮忙

我的代码如下所示

@Html.DropDownListFor(model => model.ReportingAgencies, new SelectList(Model.ReportingAgencies, "SelectedAgency.AgencyGuid", "SelectedAgency.Name"), "--Select An Agency--", new { id = "dropDownReportAgencies" })
                </td>                 
            </tr>
            <tr class="seperator"></tr>
            <tr class="seperator"></tr>

            <tr>
                <td style="width: 100px;">@Html.LabelFor(model => model.W2StateLocal.Wages)</td> 
                <td> @Html.EditorFor(model => model.W2StateLocal.Wages)</td> 
            </tr>
            <tr>
                <td style="width: 100px;">@Html.LabelFor(model => model.W2StateLocal.Tax)</td> 
                <td>@Html.EditorFor(model => model.W2StateLocal.Tax)</td> 
            </tr>
        </table>
        <div id="rightButtonControls">        
            @if (Model.IsEditable)
            {
                <button id="btnSave" value="save">Save</button>                
            }
        </div>    
    </fieldset>
}

        @Html.HiddenFor(model => model.CompanyId, new { id = "CompanyId" })
        @Html.HiddenFor(model => model.EmployeeId, new { id = "EmployeeId" })
        @Html.HiddenFor(model => model.FilingYear, new { id = "FilingYear" })


<script type="text/javascript">
    $(document).ready(function () {
        $("#divLoader").css('display', 'none');
        $('#dropDownReportAgencies').change(function () {
            var selectedAgency = $('#dropDownReportAgencies option:selected').val();
            alert(selectedAgency);
            var CompanyId = $('#CompanyId').val();
            var EmployeeId = $('#EmployeeId').val();
            var FilingYear = $('#FilingYear').val();
            var url = '@Url.Action("W2State", "W2Generation")';
            $.get(url, { agencyId: selectedAgency, companyId: CompanyId, employeeId: EmployeeId, filingYear: FilingYear },
                function (data) {
                }                
                );
        });
    });

但是值没有显示在文本字段中。请帮助解决这个问题

1 个答案:

答案 0 :(得分:1)

我不得不返回html(数据)而不是返回函数(数据)

相关问题