Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

JavaScript DropDownList1.ClientID help

$
0
0

Hello all,

I have been looking for a solution to be able to grab a value from a dropdown list that contains value from a SharePoint List column. I have the dropdown list populated with the SharePoint Data, but I've had a hard time finding a way to grab that data and redirect to a URL dynamically based on the value that was selected.

I recently found an article here describing exactly what I want to do http://www.nullskull.com/q/10376633/sharepoint-dropdown-with-redirect.aspx

Here is the code for ease of describing..

<script type="text/javascript">
function test() {
  var ddlReport = document.getElementById("<%=DropDownList1.ClientID%>");
  var Text = ddlReport.options[ddlReport.selectedIndex].text;
  var Value = ddlReport.options[ddlReport.selectedIndex].value;
  if (Value != "Select") {
    window.open("Page2.aspx");
  }
  //alert(Value);
}</script><asp:DropDownList runat="server" id="DropDownList1" DataValueField="IDValue" DataTextField="Ball_DO_Number" DataSourceID="spdatasource1" onchange="test()"></asp:DropDownList>

However, whenever I drop this code in I get this error message..

Error

 

Web Part Error: The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML.

Any advice would be appreciated



Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>