I have a dropdownlist that opens a new window when I select an item from the list. How can I pass a dropdownlist value to the new window in a URL?
My code looks like this:
<asp:DropDownList ID="ddlAdd" runat="server" CssClass="ddl" OnChange="javascript:openWindow('add.aspx?ddlAddValue=', 800, 885)">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:DropDownList>
This is the JavaScript function:
function openWindow(url, windowHeight, windowWidth)
{
var centerHeight = (screen.height - windowHeight) / 2;
var centerWidth = (screen.width - windowWidth) / 2;
var features = "height=" + windowHeight + ", width=" + windowWidth + ", top=" + centerHeight + ", left=" + centerWidth + ", scrollbars=" + 1;
var popUp = window.open(url, "", features);
}
You can simply refer to
this.valueto get the value of the underlying select.Also, this is easily handled in jQuery, if that’s how you roll: