Я бы хотел, чтобы я мог выбрать бренд 1 и бренд 2 и бренд 3.
Возможно ли я выбрать многооткрытые параметры из раскрывающегося списка без нажатия «strg»? Просто нажав? Как флажок, указанный в виде раскрывающегося меню? И что значения опции только что соединены в URL: Brand1,2,3 < /p>
Choose Channel
Facebook ads
Instagram ads
Choose Brand
brand 1
brand 2
brand 3
// Initialize the filters array
var filters = [];
// Initialize filters with any pre-selected values on page load
document.addEventListener("DOMContentLoaded", function() {
// Get all select elements
var selects = document.querySelectorAll('select');
// Initialize the filters array with the correct size
filters = new Array(selects.length).fill("");
// Check for any pre-selected options
selects.forEach(function(select) {
if (select.selectedIndex > 0) { // If something is selected (not the disabled option)
filters[select.id] = select.value;
}
});
// Update URL on initial load
changeURL();
});
function changeURL() {
var yourUrl = "https://yourdomain.com"; // Base URL
var queryParams = [];
// Update the current changed value
var selects = document.querySelectorAll('select');
selects.forEach(function(select) {
filters[select.id] = select.value;
});
// Build query parameters, only including valid values
selects.forEach(function(select) {
var paramName = select.name;
var paramValue = filters[select.id];
// Only add to URL if there's a valid value
if (paramValue && paramValue !== "" && paramValue !== "undefined") {
queryParams.push(paramName + "=" + paramValue);
}
});
// Add the query string if we have parameters
if (queryParams.length > 0) {
yourUrl += "?" + queryParams.join("&");
}
// Display the result
document.getElementById("test").innerHTML = yourUrl;
}
Я бы хотел, чтобы я мог выбрать бренд 1 и бренд 2 и бренд 3. Возможно ли я выбрать многооткрытые параметры из раскрывающегося списка без нажатия «strg»? Просто нажав? Как флажок, указанный в виде раскрывающегося меню? И что значения опции только что соединены в URL: Brand1,2,3 < /p>
[code]
Choose Channel Facebook ads Instagram ads
Choose Brand brand 1 brand 2 brand 3
// Initialize the filters array var filters = [];
// Initialize filters with any pre-selected values on page load document.addEventListener("DOMContentLoaded", function() { // Get all select elements var selects = document.querySelectorAll('select');
// Initialize the filters array with the correct size filters = new Array(selects.length).fill("");
// Check for any pre-selected options selects.forEach(function(select) { if (select.selectedIndex > 0) { // If something is selected (not the disabled option) filters[select.id] = select.value; } });
// Update URL on initial load changeURL(); });
function changeURL() { var yourUrl = "https://yourdomain.com"; // Base URL var queryParams = [];
// Update the current changed value var selects = document.querySelectorAll('select'); selects.forEach(function(select) { filters[select.id] = select.value; });
// Build query parameters, only including valid values selects.forEach(function(select) { var paramName = select.name; var paramValue = filters[select.id];
// Only add to URL if there's a valid value if (paramValue && paramValue !== "" && paramValue !== "undefined") { queryParams.push(paramName + "=" + paramValue); } });
// Add the query string if we have parameters if (queryParams.length > 0) { yourUrl += "?" + queryParams.join("&"); }
// Display the result document.getElementById("test").innerHTML = yourUrl; } [/code]