tutorial: add name attribute to inputs (#5649)

pull/6455/head
Nguyễn Đức Hào 4 years ago committed by GitHub
parent 4b4717b351
commit 0f92863033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,34 +11,34 @@
<h2>Size</h2> <h2>Size</h2>
<label> <label>
<input type=radio group={scoops} value={1}> <input type=radio group={scoops} name="scoops" value={1}>
One scoop One scoop
</label> </label>
<label> <label>
<input type=radio group={scoops} value={2}> <input type=radio group={scoops} name="scoops" value={2}>
Two scoops Two scoops
</label> </label>
<label> <label>
<input type=radio group={scoops} value={3}> <input type=radio group={scoops} name="scoops" value={3}>
Three scoops Three scoops
</label> </label>
<h2>Flavours</h2> <h2>Flavours</h2>
<label> <label>
<input type=checkbox group={flavours} value="Cookies and cream"> <input type=checkbox group={flavours} name="flavours" value="Cookies and cream">
Cookies and cream Cookies and cream
</label> </label>
<label> <label>
<input type=checkbox group={flavours} value="Mint choc chip"> <input type=checkbox group={flavours} name="flavours" value="Mint choc chip">
Mint choc chip Mint choc chip
</label> </label>
<label> <label>
<input type=checkbox group={flavours} value="Raspberry ripple"> <input type=checkbox group={flavours} name="flavours" value="Raspberry ripple">
Raspberry ripple Raspberry ripple
</label> </label>

@ -17,17 +17,17 @@
<h2>Size</h2> <h2>Size</h2>
<label> <label>
<input type=radio bind:group={scoops} value={1}> <input type=radio bind:group={scoops} name="scoops" value={1}>
One scoop One scoop
</label> </label>
<label> <label>
<input type=radio bind:group={scoops} value={2}> <input type=radio bind:group={scoops} name="scoops" value={2}>
Two scoops Two scoops
</label> </label>
<label> <label>
<input type=radio bind:group={scoops} value={3}> <input type=radio bind:group={scoops} name="scoops" value={3}>
Three scoops Three scoops
</label> </label>
@ -35,7 +35,7 @@
{#each menu as flavour} {#each menu as flavour}
<label> <label>
<input type=checkbox bind:group={flavours} value={flavour}> <input type=checkbox bind:group={flavours} name="flavours" value={flavour}>
{flavour} {flavour}
</label> </label>
{/each} {/each}

@ -7,7 +7,7 @@ If you have multiple inputs relating to the same value, you can use `bind:group`
Add `bind:group` to each input: Add `bind:group` to each input:
```html ```html
<input type=radio bind:group={scoops} value={1}> <input type=radio bind:group={scoops} name="scoops" value={1}>
``` ```
In this case, we could make the code simpler by moving the checkbox inputs into an `each` block. First, add a `menu` variable to the `<script>` block... In this case, we could make the code simpler by moving the checkbox inputs into an `each` block. First, add a `menu` variable to the `<script>` block...
@ -27,7 +27,7 @@ let menu = [
{#each menu as flavour} {#each menu as flavour}
<label> <label>
<input type=checkbox bind:group={flavours} value={flavour}> <input type=checkbox bind:group={flavours} name="flavours" value={flavour}>
{flavour} {flavour}
</label> </label>
{/each} {/each}

Loading…
Cancel
Save