我使用一个DropDownList作为如何在JavaScript中获取DropDownList的DataTextField?
<asp:DropDownList
ID="ddlLocationName"
runat="server"
DataValueField="Guid"
DataTextField="LocationName"
AppendDataBoundItems="false"
AutoPostBack="false"
onchange="LocationChange()"
></asp:DropDownList>
,当我从下拉列表中DataTextField应显示在文本字段中选择项目。为此,我正在使用以下javascript:
function LocationChange()
{
document.getElementById ("ctl00_mainContent_ctl02_txtEventLocation").value = document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName')[document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName').selectedIndex].value
}
当下拉的DataValueField未使用时,它工作正常。但是,如果在使用下拉的DataValueField属性时如何执行所需的任务呢?
在此先感谢。
为什么不显示下拉的asp标签有问题?任何人都可以告诉我如何显示该标签? – 2008-12-16 10:53:49
阅读格式化的wiki。你可能没有把它包装在合适的代码块中。为了便于阅读,我编辑了将JS函数编码为适当的代码。 – 2008-12-16 10:56:25