Html Multiple Select Value As Comma Separated String In Get Variable June 27, 2023 Post a Comment I have set up a multi-select list as follows: ).on('submit', function(e) { e.preventDefault() var val = $('#cuisine-select').val().join(',') var name = $('#cuisine-select').attr('name') $.get('/restaurant', { _sft_category: 'saturday', [name]: val }) .done(function(data) { console.log(data) }) })Copy<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><form><selectid="cuisine-select"name="_sft_post_tag"multiple="multiple"tabindex="-1"class="select2-hidden-accessible"aria-hidden="true"><optionvalue="banting">Banting</option><optionvalue="pasta">Pasta</option><optionvalue="pizza">Pizza</option><optionvalue="seafood">Seafood</option><optionvalue="vegan">Vegan</option><optionvalue="vegetarian">Vegetarian</option></select><buttontype="submit">Submit</button></form>CopySolution 2: Eventually my answer was as simple as:$('#form-specials').on('submit', function(e) { e.preventDefault(); var cuisines = $('#cuisine-select').val().join(','); var day = $('#day-select').val(); window.location = 'restaurant?_sft_category=' + day + "&_sft_post_tag=" + cuisines; }); Copy
Post a Comment for "Html Multiple Select Value As Comma Separated String In Get Variable"