SURVEY

In this example below you will see how to do a SURVEY with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by blackbirdabhi, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright blackbirdabhi ©
  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>SURVEY</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div id="main"><h1 id="title">Survey Form</h1>
<div id="form-outer">
  <p id="description">
Please fill the given survey so that we can understand your needs better. 
  </p>
  <form id="survey-form" method="GET" action="https://crossorigin.me/https://freecodecamp.com">
    <div class="rowTab">
      <div class="labels">
        <label id="name-label" for="name">Name: </label>
      </div>
      <div class="rightTab">
        <input autofocus type="text" name="name" id="name" class="input-field" placeholder="Enter your name" required>
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label id="email-label" for="email">Email: </label>
      </div>
      <div class="rightTab">
        <input type="email" name="email" id="email" class="input-field" required placeholder="Enter your Email">
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label id="number-label" for="age">Age: </label>
      </div>
      <div class="rightTab">
        <input type="number" name="age" id="number" min="1" max="125" class="input-field" placeholder="Age">
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label for="currentPos">Which option best describes your current role?</label>
      </div>
      <div class="rightTab">
        <select id="dropdown" name="currentPos" class="dropdown">
      <option disabled value>Select an option</option>
      <option  value="student">Student</option>
      <option value="job">Full Time Job</option>
      <option value="learner">Full Time Learner</option>
      <option value="preferNo">Prefer not to say</option>
      <option value="other">Other</option>
    </select>
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label for="userRating"> Would you say that you are an introvert?</label>
      </div>
      <div class="rightTab">
        <ul style="list-style: none;">
          <li class="radio"><label>Definitely<input name="radio-buttons" value="1"  type="radio" class="userRatings" ></label></li>
          <li class="radio"><label>Maybe<input name="radio-buttons" value="2"  type="radio" class="userRatings" ></label></li>
          <li class="radio"><label>Not sure<input name="radio-buttons" value="3"  type="radio" class="userRatings" ></label></li>
        </ul>
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label for="most-like">What do you like the most about social networking sites? </label>
      </div>
      <div class="rightTab">
        <select id="most-like" name="mostLike" class="dropdown">
      <option disabled selected value>Select an option</option>
      <option value="challenges">Chatting</option>
      <option value="projects">Posts</option>
      <option value="community">Discovering new friends</option>
    
    </select>
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label for="preferences">What type of music do you like?<br>(Check all that apply): </label>
      </div>
      <div class="rightTab">
        <ul id="preferences" style="list-style: none;">
          <li class="checkbox"><label><input name="prefer" value="1" type="checkbox" class="userRatings">Rock</label></li>
          <li class="checkbox"><input name="prefer" value="2" type="checkbox" class="userRatings">Pop</li>
          <li class="checkbox"><label><input name="prefer" value="3" type="checkbox" class="userRatings">Classical</label></li>
          <li class="checkbox"><label><input name="prefer" value="4" type="checkbox">Metal</label></li>
          <li class="checkbox"><label><input name="prefer" value="5" type="checkbox" class="userRatings">Jazz</label></li>
          <li class="checkbox"><label><input name="prefer" value="6" type="checkbox" class="userRatings">Sould Rockr</label></li>
          <li class="checkbox"><label><input name="prefer" value="7" type="checkbox" class="userRatings">Hip-Hop</label></li>
          <li class="checkbox"><label><input name="prefer" value="8" type="checkbox" class="userRatings">Hard Rock</label></li>
         
        </ul>
      </div>
    </div>
    <div class="rowTab">
      <div class="labels">
        <label for="comments">Any Comments or Suggestions?</label>
      </div>
      <div class="rightTab">
        <textarea id="comments" class="input-field" style="height:50px;resize:vertical;" name="comment" placeholder="Enter your comment here..."></textarea>
      </div>
    </div>
    <button class="submit" id="submit"type="submit">Submit</button>
    
  </form>
</div>
  <
</div>
  <script src='https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/blackbirdabhi/survey-wemoRx */
@import url(https://fonts.googleapis.com/css?family=Raleway:400,500);

html,
body {
  background: linear-gradient(red, yellow);
  text-align: center;
  font-family: 'Raleway', Helvetica, sans-serif;
  min-width: 320px;
}

header {
  font-size: 2em;
  font-weight: bold;
  margin: 20px;
}

#form-outer {
  background-color: #A9EBE1;
  margin: 0 auto;
  border-radius: 50px;
  width: 75%;
  max-width: 900px;
  padding: 10px;
  padding-top: 20px;
}

.labels {
  display: inline-block;
  text-align: right;
  width: 40%;
  padding: 5px;
  vertical-align: top;
  margin-top: 10px;
 
}

.rightTab {
  display: inline-block;
  text-align: left;
  width: 48%;
  vertical-align: middle;
}

.input-field {
  height: 20px;
  width: 280px;
  padding: 5px;
  margin: 10px;
  border: 1px solid #c0c0c0;
  border-radius: 2px;
}

#userAge {
  width: 40px;
}

.userRatings,
input[type="checkbox"] {
  float: left;
  margin-right: 5px;
}

.submit {
  background-color: #59ace0;
  border-radius: 25px;
  color: white;
  font-size: 1em;
  height: 40px;
  width: 96px;
  margin: 10px;
  border: 0px solid;
 
  }

.submit:hover{
   animation-name: btn;
  animation-duration: 500ms;
    animation-fill-mode: forwards;
}

.dropdown {
  height: 35px;
  width: 140px;
  padding: 5px;
  margin: 10px;  
  margin-top: 15px;
  border: 1px solid #c0c0c0;
  border-radius: 2px;
}

.radio, .checkbox {
  position: relative;
  left: -43px;
  margin-left: 10px;
  display: block;
  padding-bottom: 10px;
}

@media screen and (max-width: 833px) {
  .input-field {
    width: 80%;
  }
  select {
    width: 90%;
  }
}

@media screen and (max-width: 520px) {
  .labels {
    width: 100%;
    text-align: left;
  }
  .rightTab {
    width: 80%;
    float: left;
  }
  .input-field {
    width: 100%;
  }
  select {
    width: 100%;
  }
}
 @keyframes btn{
    100% {
      background-color: red;
    }
   img.resize {
    height: auto; 
    width: auto; 
    max-width: 300px; 
    max-height: 300px;
}

/*Downloaded from https://www.codeseek.co/blackbirdabhi/survey-wemoRx */
// !! IMPORTANT README:

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. 

/***********
INSTRUCTIONS:
  - Select the project you would 
    like to complete from the dropdown 
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank 
    pen.
  - Click the "TESTS" button to see 
    the individual test cases. 
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go   
    from red to green.
  - As you start to build out your 
    project, when tests are failing, 
    you should get helpful errors 
    along the way!
    ************/

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments.

Comments