I need to filter my list based on selected dropdown value. I've created a DVWP for that and converted it into a dropdown. Now I'm following this post to fire events when dropdown value is selected but I just do not know where to change the code. I'm filtering the list based on years. I have an year list which stores year values and filters it accordingly when the dropdown is selected. I've modified it like this:
<xsl:otherwise>
<select name="ID" size="1" onchange="document.location.href='pageName.aspx?year=' + this.options[selectedIndex.value])">
<option selected="true" value="0">Choose One...</option>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows" />
</xsl:call-template>
</select>
I've no idea of xslt and this isn't firing any event when i change the dropdown value. Please help me with this.
Update: The HTML I get:
<td valign="top">
<div WebPartID="9e0da2fd-21ea-417f-863d-6551d16e72a1" HasPers="false" id="WebPartWPQ3" width="100%" class="noindex" allowDelete="false" style="" >
<select name="ID" size="1" onchange="document.location.href='http://pageName.aspx?year=' + this.options[selectedIndex].value" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<option selected="" value="0">Choose One...</option>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
</select>
</div>
</td>
I'm somewhat doubtful that this is an XSLT issue. The script for the onchange
handler in that tutorial seems to boil down to:
document.location.href='pageName.aspx?year=' + this.options[selectedIndex].value
Note that .value
is outside the []
. Could you give that a try? Is your browser reporting any JavaScript errors when you change the dropdown selection?
Now, according to this tutorial, you can filter a list by specifying query parameters named FilterField1
, FilterValue1
, etc, so could you try something like this:
document.location.href='pageName.aspx?FilterField1=ColumnName&FilterValue1='
+ this.options[selectedIndex].value + '&year=' + this.options[selectedIndex].value
Here you would replace "ColumnName" with the actual name of the column, as indicated in that tutorial. Could you try something like that?