我的下拉列表(填充有objectDataSource
):
<asp:DropDownList runat=server ID="ddlUserTypes" DataSourceID="odsUserTypes" AppendDataBoundItems=true DataTextField="UserType" DataValueField="Usertype">
<asp:ListItem Value="">-Please select one-</asp:ListItem>
</asp:DropDownList>
获取下拉列表的选定值的 Javascript 函数:
<script type="text/javascript" language="javascript">
var notRegistered = false;
var email = '';
var userType = document.getElementById("ddlUserTypes");
var pow = userType.options[userType.selectedIndex].value;
function PreRegister() {debugger;
if (notRegistered) {
location.href = '/Register.aspx?pageid=<%= ConfigHelper.RegistrationPageId %>&Email=' + encodeURIComponent(email)+'&asd='+encodeURIComponent(pow);
return false;
}
return true;
}
</script>
但这不起作用pow
只是继续返回未定义?这可能是因为用户类型似乎没有得到任何分配给它的东西,因为它保持为空?有谁知道为什么这段代码不起作用?