<a id="m1" class="audio {autoPlay:false, addGradientOverlay:true}"
href="MusicFolder/" + document.getElementById("DropDownList1").value + "/" +
document.getElementById("DropDownList2").value>document.getElementById("DropDownList2").value</a>
我在我的aspx网页上面得到了上面的代码,但它没有用。我试图通过组合两个下拉列表选择值来获取可变文件路径。请任何人帮助我做错了什么,如何纠正上面的代码。
Drowpdown asp.net代码位于
之下 <asp:DropDownList runat="server" id="DropDownList1" AutoPostBack="True" DataSourceID="AccessDataSource6" DataTextField="TranslationLang" DataValueField="TranslationLang" Height="25px" Width="100%"></asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource6" runat="server" DataFile="Database/HFx.mdb" SelectCommand="SELECT [TranslationLang] FROM [Translation]">
</asp:AccessDataSource>
<br />
<asp:DropDownList runat="server" id="DropDownList2" AutoPostBack="True" DataSourceID="AccessDataSource7" DataTextField="Surah" DataValueField="Surah" Height="25px" Width="100%"></asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource7" runat="server" DataFile="Database/HFx.mdb" SelectCommand="SELECT [Surah] FROM [TranslationSurah] WHERE ([Lang] = ?) ORDER BY [No]">
<SelectParameters>
<asp:controlparameter ControlID="DropDownList1" Name="Lang" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
答案 0 :(得分:0)
浏览器只在单击时才在href中执行JS,但为此需要在href内容的开头提及“javascript:”。以下代码应该可以使用
<a id="m1" class="audio {autoPlay:false, addGradientOverlay:true}"
href="javascript:window.location='MusicFolder/' + document.getElementById('DropDownList1').value + '/' + document.getElementById('DropDownList2').value">document.getElementById('DropDownList2').value</a>