本文介绍了如何使用Ajax满足以下要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我的项目中有一个如下要求:
我应该将表中指定列的所有值都放入下拉列表中,并且在该下拉列表中选择不同的值时,文本框的值应该更改.文本框上的值将来自同一表.

我需要为此使用AJAX吗?如果是,那么让我知道如何使用,就像我之前从未使用过AJAX一样.

Hi..
I have a requirement in my project which is something like this:
I am supposed to bring all the values of a specified column from a table into my drop down and on selection of different values in that drop down the values of the text box should change. The value on text box will come from the same table .

DO i need to use AJAX for this? If yes then let me know how to use as in I have never used AJAX before this.
Is there any other way to get that?

推荐答案

<select id="dropdown">
@foreach (var record in Model) {
   // I suspect you know what is Model
   <option value="@record.Id">
      @record.Name
   </option>
   // Assume Model is [{Id = 1, Name = "Afzaal Ahmad Zeeshan"}, ...]
}
</select>
</select>



这将为您的记录(在模型中返回)创建一个下拉列表,现在您可以处理change事件并在示例HTML区域上显示数据.



This will create the dropdown for your records (that you returned in the Model), now you can handle the change event and show the data on the sample HTML area.

<div id="dropzone">
  <!-- This will hold the data -->
</div>



用于处理事件的jQuery代码将在此处



The jQuery code that will handle the event will be here,




这篇关于如何使用Ajax满足以下要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 13:48
查看更多