我有一个自动完成文本框和一个从数据库填充的下拉列表现在我想从我从下拉列表中选择一个项目文本框填充该项目
问题描述:
我有一个文本框,从数据库中填充
和下拉列表,也是从数据库填充的。
所以现在我想,当我在下拉列表中选择一个元素时,文本字段填充该元素
我从数据库通过[webmethod]填充的文本框.as it可能
I have a textbox which is filled from database
and dropdown list which is also filled from database.
So now i want, when i select a element in dropdown list the textfield fill against that element
the textbox which i fill from database through a [webmethod].as it possible
答
只需使用onchange
DropDownList
的事件并在该事件上调用 JavaScript 方法。使用 jQueryAjax
并调用WebMethod
。
在WebMethod
中,连接到数据库并获取必要的数据并返回 jQueryAjax
呼叫。然后在成功
块的Ajax
调用中分配返回数据。
Just useonchange
Event forDropDownList
and call a JavaScript method on that Event. Use jQueryAjax
and call aWebMethod
.
Inside theWebMethod
, connect to Database and fetch necessary data and return to the jQueryAjax
call. Then assign that return data inside thesuccess
block ofAjax
call.