Survey Form - Build a Survey Form

Tell us what’s happening:
I’ve done everything so far but i can’t seem to get with is wrong with my radio button

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head></head>
<title>Survey Form</title>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<body>
  <h1 id="title">Survey Form</h1>
  <p id="description">Please fill out this form with the required information</p>
<form id="survey-form">
<fieldset>
  <label for="name" >Name<input id="name" type="text" placeholder="Enter your name" required/></label>
  <label for="email">Email<input id="email" type="email" placeholder="Enter your email" required/></label>
  <label for="number">Number<input id="number" type="number" min="12" max="120" placeholder="age" required /></label>
  <input type="submit" value="submit" />
</fieldset>
<fieldset>Are you new here?
  <label id="name-label"><input name="yes" type="radio" value="yes"/>Yes</label>
  <label id="email-label"><input name="no" type="radio" value="no"/>No</label>
  <label id="number-label"><input type="checbox" value="" required />how did you hear about us?</label>
  <label><input type="checkbox" /></label>
   <select id="dropdown">
    <option></option>
    <option></option>
  </select>
</fieldset>
</form>
</body>

/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.69

Challenge: Survey Form - Build a Survey Form

Link to the challenge:

Your radio buttons need to have the same name attribute to fulfil the requirement ‘Every radio button group should have at least 2 radio buttons.’

please can you be a little more specific on that

You have two radio buttons here, with the labels Yes and No. You’ve given them different name attributes, yes and no respectively. If you click on both of them, you’ll see that both become selected. This is not the purpose of radio buttons - they are meant to be used to select only one option.

When you give them the same name attribute (make the value of name the same for both) they become grouped, meaning they cannot be selected at the same time, fulfilling the requirement I mentioned. Sorry for any confusion.

1 Like

sorry for bringing you back to this, i did what you said and i got it correctly but now it’s saying this:
All your radio buttons should have a name attribute and value.

<!DOCTYPE html>
<html lang="en">
<head></head>
<title>Survey Form</title>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<body>
  <h1 id="title">Survey Form</h1>
  <p id="description">Please fill out this form with the required information</p>
<form id="survey-form">
<fieldset>
  <label for="name" >Name<input id="name" type="text" placeholder="Enter your name" required/></label>
  <label for="email">Email<input id="email" type="email" placeholder="Enter your email" required/></label>
  <label for="number">Number<input id="number" type="number" min="12" max="120" placeholder="age" required /></label>
  <input type="submit" value="submit" />
</fieldset>
<fieldset>Are you new here?
  <label id="name-label" ><input  type="radio" value="yes"/>Yes</label>
  <label id="email-label" ><input  type="radio" value="no"/>No</label>
  <label id="number-label"><input type="checbox" value="" required />how did you hear about us?</label>
  <label><input type="checkbox" /></label>
   <select id="dropdown">
    <option></option>
    <option></option>
  </select>
</fieldset>
</form>
</body>

<label id="name-label" ><input  type="radio" value="yes"/>Yes</label>
 <label id="email-label" ><input  type="radio" value="no"/>No</label>

You’ve deleted the name attributes, which is why the code is failing that condition. You need to add name attributes with the same value attributed to them into both input elements.

As an example, try adding name="answer" to both lines above within their respective input elements.

Thank you so much. you really got me outta a tight spot, I’ve been stuck all week on that radio button.
I’ll read and practice more.

1 Like