Open new window passing the text and value of a dropdownlist on onClientClick of button in aspx page
I am making my site compatible to all browsers. For that on one page I am selecting the name from dropdownlist and on click of VIEW (button), I want to open a new window. I also want to send the value and text of ddl on new window.
All of this I want to do on onClientClick or onClick of button...
For getting the value I have tried this code:
input name="button1" type="button" id="btnview" style="cursor:hand" class="Buttons" title="View" value="View" onclick="alert(document.all('<%=ddlScheme.ClientID%>').value);"
(this code is in angular braces < and / >)
And I got an alert with the value. I am just trying to alert the value and text first so that I can check my code on initial level.
For getting the text of ddl I have tried:
onclick="alert(document.all('<%=ddlScheme.ClientID%>')(document.all('<%=ddlScheme.ClientID%>').selectedIndex).text)
The change is in the onClick only, and here I'm not getting the text. Basically I have to do exactly this, I don't know if I'm right or not.
OnClick="window.开发者_Python百科open('../Reports/ReportCourtCaseDetail.aspx?SchemeId=' + document.getElementById('ddlScheme').value + "&SchemeName=" + document.all('<%=ddlScheme.ClientID%>')(document.all('<%=ddlScheme.ClientID%>').selectedIndex).text' ,'newWindow_CourtCaseDetail','location=no,fullscreen=no,menubar=no,titlebar=yes,status=no,toolbar=no,scrollbars=yes,resizable=yes');
but through this code I'm not getting any new window.
to get the selected value try this way instead:
document.getElementById('<%=ddlScheme.ClientID%>').options[document.getElementById('<%=ddlScheme.ClientID%>').selectedIndex].value;
精彩评论