3.7 KiB
id | title | challengeType | dashedName |
---|---|---|---|
5f1a80975fc4bcae0edb3497 | Step 48 | 0 | step-48 |
--description--
Se selezioni il pulsante di opzione Indoor
e invii il modulo, i dati del modulo per il pulsante si basano sugli attributi name
e value
. Dal momento che i pulsanti di opzione non hanno un attributo value
, i dati del modulo includeranno indoor-outdoor=on
, che non è utile quando hai più pulsanti.
Aggiungi un attributo value
a entrambi i pulsanti di opzione. Per comodità, imposta l'attributo value
del pulsante con lo stesso valore dell'attributo id
.
--hints--
Entrambi i pulsanti di opzione dovrebbero essere ancora posizionati tra i tag di apertura e chiusura dell'elemento label
.
const labelChildNodes = [...document.querySelectorAll('form > label')].map(
(node) => node.childNodes
);
assert(
labelChildNodes.filter((childNode) => childNode[0].nodeName === 'INPUT')
.length === 2
);
Entrambi i pulsanti di opzione dovrebbero avere un attributo value
. Verifica che ci sia uno spazio dopo il nome del tag di apertura e/o che ci siano spazi prima di tutti i nomi degli attributi.
const radioButtons = [...document.querySelectorAll('input[type="radio"]')];
assert(radioButtons.every((btn) => btn.hasAttribute('value')));
L'attributo value
del pulsante di opzioneIndoor
dovrebbe avere il valore indoor
. Hai omesso il valore o hai un refuso. Ricorda che i valori degli attributi devono essere racchiusi tra virgolette.
const indoorRadioButton = document.querySelector('#indoor');
assert(indoorRadioButton.getAttribute('value').match(/^indoor$/));
L'attributo value
del pulsante di opzione Outdoor
dovrebbe avere il valore outdoor
. Hai omesso il valore o hai un refuso. Ricorda che i valori degli attributi devono essere racchiusi tra virgolette.
const outdoorRadioButton = document.querySelector('#outdoor');
assert(outdoorRadioButton.getAttribute('value').match(/^outdoor$/));
--seed--
--seed-contents--
<html>
<body>
<h1>CatPhotoApp</h1>
<main>
<section>
<h2>Cat Photos</h2>
<!-- TODO: Add link to cat photos -->
<p>Click here to view more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a>.</p>
<a href="https://freecatphotoapp.com"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<section>
<h2>Cat Lists</h2>
<h3>Things cats love:</h3>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg" alt="A slice of lasagna on a plate.">
<figcaption>Cats <em>love</em> lasagna.</figcaption>
</figure>
<h3>Top 3 things cats hate:</h3>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg" alt="Five cats looking around a field.">
<figcaption>Cats <strong>hate</strong> other cats.</figcaption>
</figure>
</section>
<section>
<h2>Cat Form</h2>
<form action="https://freecatphotoapp.com/submit-cat-photo">
--fcc-editable-region--
<label><input id="indoor" type="radio" name="indoor-outdoor"> Indoor</label>
<label><input id="outdoor" type="radio" name="indoor-outdoor"> Outdoor</label>
--fcc-editable-region--
<input type="text" name="catphotourl" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</section>
</main>
</body>
</html>