Options with empty value will not be shown
See original GitHub issue<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.4.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
</head>
<body>
<select name="SSS" id="SSS">
<option value=""> </option>
<option value="1">S0</option>
<option selected="selected" value="2">S1</option>
<option value="3">S2</option>
</select>
<script>
$(document).ready(function () {
$("#SSS").select2({
placeholder: "",
width: "resolve"
});
});
</script>
</body>
</html>
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
show empty value in html select element - Stack Overflow
I want to let the user know that the value I got from the server is not a valid option. What I'd like...
Read more >Handling Null and Other Special Values - Tableau Help
Show Data at Default Position - show the data at a default location on the axis. The null values will still be included...
Read more >Should a blank option always be included in <select> inputs?
It just seems slightly strange to change the options of required <select> fields based on whether the value has previously been set. This...
Read more >Blank, Coalesce, IsBlank, and IsEmpty functions in Power Apps
Some controls and data sources use an empty string to indicate a "no value" condition. To simplify app creation, the IsBlank and Coalesce ......
Read more >Changing the display of null values - MicroStrategy
Clear the Use default check box under Null display settings. · If desired, enter the value to be displayed when an empty value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
An empty placeholder option is unlikely to contain a value=“” attribute, whereas null options will include this. It’s not hard to distinguish between the two.
I think this should be looked into again, as the current implementation requires someone to write more code to initialise select2 on elements that should show these options.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.