0
我正嘗試使用用戶從更新breadcrumbs最後一個值的列表框中進行選擇來創建麪包屑。 我已經開始工作了,但您無法點擊「主頁」或「商店」以轉到上一頁。所以我嘗試添加鏈接到我的腳本中的值,但它繼續打印與字符串的鏈接,而不是隻是使字符串鏈接。 任何提示?用於創建與每個麪包屑鏈接的麪包屑的Javascript?
$("select")
.change(function() {
var val = "";
var str1 = "Home";
var str2 = "Store";
var str3 = str1.link("home.php") + "/" + str2.link("store.php") + "/" + val;
$("select option:selected").each(function() {
val = $(this).text();
});
$(".breadcrumbs").text(str3);
})
.change();
這是我的HTML & PHP它是從我的數據庫中提取不同的項目和填充一個列表框:
<div class="breadcrumbs col-sm-4">
<!-- Update this based on the selected box using the script at the bottom of the page-->
<!-- bread crumbs -->
</div>
<div class="col-sm-offset-3 col-sm-2">
<select id="productselect" class="form-control" name="category">
<option value="All Products">All Products</option>
<!-- Populate the listbox with distinct category of items from the database -->
<? do { ?>
<option value='"$row[0]"'>
<?="$row[0]" ?>
</option>;
<? } while($row=m ysqli_fetch_array($result)) ?>
</select>
<? mysqli_free_result($result); mysqli_close($db); ?>
</select>
</div>
啊,非常感謝!我沒有意識到.text會拋棄它。現在起作用了。 – Haley