Default value not working in select
See original GitHub issueThe default select value is not applied to the select widget.
<script>
var users = {
1: {name: "aaa"},
2: {name: "bbb"},
3: {name: "ccc"},
};
var user_id=2;
</script>
<select value={user_id}>
{#each Object.entries(users) as [k, v]}
<option value={k}>{v.name}</option>
{/each}
</select>
https://svelte.dev/repl/895418a4cb0249a1af034cfbb71e7ae6?version=3.24.0
I expect bbb to be selected.
Chrome Version 83.0.4103.116 (Official Build) (64-bit) Windows 7
It’s strange, not too severe.
If I change the type of user_id
to string it works, but why should I?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Default option of select is not showing - Stack Overflow
The default option will be selected if the value attribute of the option tag is set to the default value of the selectedOption...
Read more >How to set the default value for an HTML <select> element
The default value of the select element can be set by using the 'selected' attribute on the required option. This is a boolean...
Read more >why default value is not working in select box var... - ServiceNow
i have select box variable o incident form having 3 question choices, out of which i have marked value 3 as default but...
Read more >Default option in select field is not working - Prismic People
Hello, I have a background select field with two options - white and dark. The "white" option is the default one.
Read more >[SOLVED] Default value in SELECT field not working
Hello, how to set default value in select field. I added in PA -> fields -> field -> Show in registration + Default...
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 Free
Top 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
@axil
each
more performant, but not absolutely sure.Fetch.svelte
@antony Nevermind! I’m still a big fan of svelte and I appreciate the efforts you make to support and maintain it.
@afaur Actually, in my particular case the indices of the users are taken from the database and can contain gaps when they are deleted.
What about this variant – just one symbol to fix the problem: