Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Showing Questions Below Answers After The Submit Button Is Pressed?

Showing Questions Below Answers After The Submit Button Is Pressed?

Scheduled Pinned Locked Moved JavaScript
questiontutorialcareer
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KeonD123
    wrote on last edited by
    #1

    I've got ten questions here. All questions have two possible answers but only one is correct and I would like to know how to make the answer appear underneath its question after the submit button is pressed. Also sorry if you find some of the questions offensive but that's the kind of demographic I'm trying to reach out to. Anyway here's the code:

    <p class="question">1.Would you rather be 2 foot tall or 10 foot tall?</p>
    <input id="q1a" type="radio" name="q1" value="a" /><label for="q1a"> 2 foot tall</label>
    <input id="q1b" type="radio" name="q1" value="b" /><label for="q1b"> 10 foot tall</label>

    <p class="question">2.Would you rather be blind or deaf?</p>
    <input id="q2a" type="radio" name="q2" value="a" /><label for="q2a"> Blind</label>
    <input id="q2b" type="radio" name="q2" value="b" /><label for="q2b"> Deaf</label>

    <p class="question">3.Would you rather be poor and work at a job you love or be rich and work at a job you hate?</p>
    <input id="q3a" type="radio" name="q3" value="a" /><label for="q3a"> Poor and love my job</label>
    <input id="q3b" type="radio" name="q3" value="b" /><label for="q3b"> Rich and hate your job</label>

    <p class="question">4.Would you rather be homeless and have family and friends or not be homeless and live without family?</p>
    <input id="q4a" type="radio" name="q4" value="a" /><label for="q4a"> Homeless with family and friends</label>
    <input id="q4b" type="radio" name="q4" value="b" /><label for="q4b"> Not homeless without family and friends</label>

    <p class="question">5.Would you rather have no legs or no arms?</p>
    <input id="q5a" type="radio" name="q5" value="a" /><label for="q5a"> No legs</label>
    <input id="q5b" type="radio" name="q5" value="b" /><label for="q5b"> No arms</la

    T 1 Reply Last reply
    0
    • K KeonD123

      I've got ten questions here. All questions have two possible answers but only one is correct and I would like to know how to make the answer appear underneath its question after the submit button is pressed. Also sorry if you find some of the questions offensive but that's the kind of demographic I'm trying to reach out to. Anyway here's the code:

      <p class="question">1.Would you rather be 2 foot tall or 10 foot tall?</p>
      <input id="q1a" type="radio" name="q1" value="a" /><label for="q1a"> 2 foot tall</label>
      <input id="q1b" type="radio" name="q1" value="b" /><label for="q1b"> 10 foot tall</label>

      <p class="question">2.Would you rather be blind or deaf?</p>
      <input id="q2a" type="radio" name="q2" value="a" /><label for="q2a"> Blind</label>
      <input id="q2b" type="radio" name="q2" value="b" /><label for="q2b"> Deaf</label>

      <p class="question">3.Would you rather be poor and work at a job you love or be rich and work at a job you hate?</p>
      <input id="q3a" type="radio" name="q3" value="a" /><label for="q3a"> Poor and love my job</label>
      <input id="q3b" type="radio" name="q3" value="b" /><label for="q3b"> Rich and hate your job</label>

      <p class="question">4.Would you rather be homeless and have family and friends or not be homeless and live without family?</p>
      <input id="q4a" type="radio" name="q4" value="a" /><label for="q4a"> Homeless with family and friends</label>
      <input id="q4b" type="radio" name="q4" value="b" /><label for="q4b"> Not homeless without family and friends</label>

      <p class="question">5.Would you rather have no legs or no arms?</p>
      <input id="q5a" type="radio" name="q5" value="a" /><label for="q5a"> No legs</label>
      <input id="q5b" type="radio" name="q5" value="b" /><label for="q5b"> No arms</la

      T Offline
      T Offline
      twseitex
      wrote on last edited by
      #2

      var TrueArray=new Array // numbers only of correct inputs ( 2, // 1 so fist input is correct, 2 so second input is correct ... // false second input is correct ); var TrueArrayLength=TrueArray.length; insert function onkeypress or onmousewover ... what you want 2 foot tall function GetTrueFalse(NumberOfQuestion,NumberOfCorrectfInput) // NumberOfQuestion from 1 to TrueArrayLength // NumberOfCorrectfInput value of field of array at index pos NumberOfQuestion-1 { NumberOfQuestion--; if((NumberOfQuestion>=0) && (NumberOfQuestion0) && (NumberOfCorrectfInput<3)) // 1 or 2 { if(NumberOfCorrectfInput==TrueArray[NumberOfQuestion]) // got number of correct input ? { // correct e.g. alert("bingo!"); } else { // not correct e.g. alert("nope"); } } } } have fun.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups