Search results
26 lut 2009 · You can take all your "selected values" by the name of the checkboxes and present them in a sting separated by ",". A nice way to do this is to use jQuery's $.map(): var selected_val = $.map($("input[name='d_name']:checked"), function(a) { return a.value; }).join(','); alert(selected_val);
14 lip 2010 · Using the .val() function on a multi-select list will return an array of the selected values: var selectedValues = $('#multipleSelect').val(); and in your html: <select id="multipleSelect" multiple="multiple"> <option value="1">Text 1</option> <option value="2">Text 2</option> <option value="3">Text 3</option> </select>
1 maj 2021 · This post will discuss how to get all selected values of a multi-select dropdown list with jQuery. With jQuery, you can use the .val() method to get an array of the selected values on a multi-select dropdown list.
The .val() method is primarily used to get the values of form elements such as input, select and textarea. When called on an empty collection, it returns undefined. When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), .val() returns an array containing the value of each selected ...
24 kwi 2024 · This post will discuss how to get all options of a select in JavaScript and jQuery. 1. Using jQuery. With jQuery, you can use the .each() method, which is a concise and less error-prone way to iterate over the DOM elements.
24 mar 2023 · The .val() function in JQuery can be used to get the value of the selected options in a select element. Here is the code: var selectedValues = $('#mySelect').val();
1 gru 2023 · Getting the selected option from a dropdown list is a common task in jQuery, and understanding how to do it is crucial for form handling. By using the `val ()`, `text ()`, and `:selected` methods, you can easily get the value or text of the selected option.