Jump to content

ahaberman25

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by ahaberman25

  1. The things I have tried to do to code this out have not had the result I am wishing for this. I believe it goes a little past the knowledge that i know of js and jquery
  2. was also thinking of taking "slick quiz" and converting it to accept text field numeric answers. cant upload them though
  3. I am trying to build a jquery quiz using the numbers added in the text fields for each answer, then adding up the answers at the end once submitted and based on the answers like (answer < 6 output: something) and so forth. the code i have so far is : <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script src="js/jquery-1.8.2.js"></script> <script src="js/jquery.validate.js"></script> <script> $(document).ready(function() { function mySubmitHandler() { // the following are just examples of what you could do var q1val = $('#txt1').val(); var q2val = $('#txt2').val(); if(q1val + q2val > 5) $('#success').show(); else $('#fail').show(); // end example return false; // this keeps the form from doing a postback } }); // end ready </script> <title></title> <style> input { float:right; } </style> </head> <body id="main-content"> <div id="container"> <h1>Take the Sleep Disorder Self-Quiz -<br />Epworth Sleepiness Scale</h1> <p><span style="font-size: 10pt;">How likely are you to doze off or fall asleep in the following situations, in contrast to just feeling tired? This refers to your usual way of life in recent times. Even if you have not done some of these things recently, try to work out how they would have affected you. Use the following scale and enter the number for each situation.</span></p> <div> <p style="text-align: left; margin-left: 180px;"><strong>0</strong> = no chance of dozing<br /> <strong>1</strong> = slight chance of dozing<br /> <strong>2</strong> = moderate chance of dozing<br /> <strong>3</strong> = high chance of dozing</p> </div> <!-- start form --> <form id="myform" onsubmit="return mySubmitHandler()"> <fieldset> <legend>Quiz</legend> <h3><span style="text-decoration: underline;">SITUATION</span><span style="text-decoration: underline; float:right;">Chance of dozing</span></h3> <label for="txt1">Sitting and reading</label> <input type="text" class="qi" name="txt1" id="txt1" size="5" tabindex="1" value="0" /> <br /> <br /> <label for="txt2">Watching TV</label> <input type="text" class="qi" name="txt2" id="txt2" size="5" tabindex="2" value="0" /> <br /> <br /> <label for="txt3">Sitting inactive in a public place (Such as a theatre or a meeting)</label> <input type="text" class="qi" name="txt3" id="txt3" size="5" tabindex="4" value="0" /> <br /> <br /> <label for="txt4">As a passenger in a car for an hour without a break</label> <input type="text" class="qi" name="txt4" id="txt4" size="5" tabindex="5" value="0" /> <br /> <br /> <label for="txt5">Lying down to rest in the afternoon when time permits</label> <input type="text" class="qi" name="txt5" id="txt5" size="5" tabindex="6" value="0" /> <br /> <br /> <label for="txt6">Sitting and talking to someone</label> <input type="text" class="qi" name="txt6" id="txt6" size="5" tabindex="7" value="0" /> <br /> <br /> <label for="txt7">Sitting quietly after lunch without alcohol</label> <input type="text" class="qi" name="txt7" id="txt7" size="5" tabindex="8" value="0" /> <br /> <br /> <label for="txt8">In a car, while stopped for a few minutes in traffic</label> <input type="text" class="qi" name="txt8" id="txt8" size="5" tabindex="9" value="0" /> <br /> <br /> <div style="display: block clear:both;"> <div style="color: #00658f; font-size: 16px; float: left;"><strong>TOTAL SCORE</strong></div> </div> <div style="color: #00658f; font-size: 16px;"><strong><span id="total"> </span></strong></div> <input type="submit" value="submit"> </fieldset> </form> </div><!-- close container --> </body> </html> no matter what I have researched and tried its not working out for me. If anyone knows any links or any ideas please help me out. If its too much work I understand. p.s. will also be adding form validation for answers can only be 0-4 and only numeric. sleep.html
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.