簡體   English   中英

href標記中的變量路徑

[英]variable path in href tag

<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>

瀏覽器僅在單擊href時才在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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM