473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I get a calculation results box to dynamically populate a text box information

11 New Member
I have a calculating form. Once the end user hits the calculate button to get their results, we want those results to dynamically populate a text area to show them information directly related to their score.

The URL: www.sepaincare.com/rate-your-pain-quiz.html
Nov 19 '12 #1
19 2920
Dormilich
8,658 Recognized Expert Moderator Expert
you’re not satisfied with what you have?
Nov 19 '12 #2
SEMKTG
11 New Member
Actually, it has been requested and I am more of a front end developer. I can tweek code if it's close to what I need. What I haven't been able to find is a text field that will populate dynamically given a value in a calculation field.

If you went to the site, and scrolled down to the lower part; where the "If your scored 0-5". That would be the text shown depending on the value that would be populated in the "Pain Quiz Total" box.
Nov 19 '12 #3
Dormilich
8,658 Recognized Expert Moderator Expert
that is simply a question of a good condition.
Expand|Select|Wrap|Line Numbers
  1. if (6 > score) {
  2.     // show first text
  3. }
  4. else if (12 > score) {
  5.     // show second text
  6. }
  7. else {
  8.     // show third text
  9. }
Nov 19 '12 #4
SEMKTG
11 New Member
doesn't' there need to be a variable for the score or would that be

var score=""

to pull whatever the data is from the "score" field?
Nov 19 '12 #5
SEMKTG
11 New Member
I have this code but it's not seeing the field value.

Expand|Select|Wrap|Line Numbers
  1. <input type="text" class="rsform-input-box" id="total" name="form[Total]" size="20" value=""><br />
  2. <script type="text/javascript">
  3. <!--
  4. var name_element = document.getElementByName('form[Total]');
  5. var total = name_element.value;
  6. if( total <= 5 ){
  7.    document.write("<b>If you score 0-5</b>, you have minimal disability from pain but could be subject to worsening symptoms.");
  8. }else if( (total > 5) && (total < 12) ){
  9.    document.write("<b>If you score 6-11</b>, pain may be affecting your quality of life. Don’t wait for it to take over your life. Talk to one of our double board certified physicians so they can determine what treatment plan will work best for your individual needs, using the least invasive methods possible &ndash; ultimately reducing the need for medication so you can return to your healthy, pain free lifestyle.");
  10. }else {
  11.   document.write("<b>If you score higher than 12</b>, the pain you are experiencing is out of the “normal” range, and the pain symptoms are interfering with your life. Pain can diminish job performance, lower motivation to exercise and prevent you from completing daily tasks, which causes some pain sufferers to get down on themselves or to view their chronic pain as a sign of weakness or a personal defect. Don't go down that road.");
  12. }
  13. //-->
  14. </script>
Nov 19 '12 #6
Dormilich
8,658 Recognized Expert Moderator Expert
two things. in the elsse if() the total > 5 part is not necessary (if total is not > 5, it is caught in the first if())

second, the total will be calculated based on user interaction (clicking some button). at this time it is too late to use document.write(). reversely, if you call your that code, total is not yet populated.
Nov 20 '12 #7
SEMKTG
11 New Member
I appreciate the input. I adjusted the variable "total" to "score". The main reason for using total, "total" is the input id. I do have a calculate button. If it is to late to use document.write, then what should be used. My depth in javascript is shallow at best. Below is the source for the form.

Expand|Select|Wrap|Line Numbers
  1. <form action="http://www.sepaincare.com/rate-your-pain-quiz.html" enctype="multipart/form-data" id="userForm" method="post"><fieldset class="formFieldset">
  2. <legend>Rate Your Pain</legend>
  3. <div style="display: none;" id="rsform_error_3"><p class="formRed">Please complete all required fields!</p></div>
  4. <!-- Do not remove this ID, it is used to identify the page so that the pagination script can work correctly -->
  5. <ol id="rsform_3_page_0" class="formContainer">
  6.     <li class="rsform-block rsform-block-intro">
  7.         <div class="formCaption2"></div>
  8.         <div class="formBody">Knowing when it is necessary to get help can be difficult. We can help you consider treatment options. Take this simple quiz to determine if seeking treatment at SEPC may be the right decision for you:<span class="formClr"></span></div>
  9.         <div class="formDescription"></div>
  10.     </li>
  11.     <li class="rsform-block rsform-block-initial-question">
  12.         <div class="formCaption2"></div>
  13.         <div class="formBody">Please Select Your Gender.<span class="formClr"></span></div>
  14.         <div class="formDescription"></div>
  15.     </li>
  16.     <li class="rsform-block rsform-block-image">
  17.         <div class="formCaption2"></div>
  18.         <div class="formBody"><img width="176" height="200" src="/images/stories/PainQuiz.png"><span class="formClr"></span></div>
  19.         <div class="formDescription"></div>
  20.     </li>
  21.     <li class="rsform-block rsform-block-question-1">
  22.         <div class="formCaption2"></div>
  23.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="Question 10" value="Female" name="form[Question 1]"><label for="Question 10">Female</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="Question 11" value="Male" name="form[Question 1]"><label for="Question 11">Male</label></div>
  24.         <div class="formDescription"></div>
  25.     </li>
  26.     <li class="rsform-block rsform-block-radio1">
  27.         <div class="formCaption2">1. On a scale from 1-10, how would you rate your pain?</div>
  28.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio10" value="0" name="form[radio1]"><label for="radio10">1-3</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio11" value="2" name="form[radio1]"><label for="radio11">3-6</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio12" value="4" name="form[radio1]"><label for="radio12">6-8</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio13" value="6" name="form[radio1]"><label for="radio13">8-10</label></div>
  29.         <div class="formDescription"></div>
  30.     </li>
  31.     <li class="rsform-block rsform-block-radio2">
  32.         <div class="formCaption2">2. True or False: You always feel pain in the part of the body where it originates</div>
  33.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio20" value="2" name="form[radio2]"><label for="radio20">True</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio21" value="4" name="form[radio2]"><label for="radio21">False</label></div>
  34.         <div class="formDescription"></div>
  35.     </li>
  36.     <li class="rsform-block rsform-block-radio3">
  37.         <div class="formCaption2">3. Do you have pain that lasts:</div>
  38.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio30" value="2" name="form[radio3]"><label for="radio30">2 to 3 Weeks </label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio31" value="4" name="form[radio3]"><label for="radio31">2 to 3 Months</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio32" value="6" name="form[radio3]"><label for="radio32">3 to 6 Months or longer</label></div>
  39.         <div class="formDescription"></div>
  40.     </li>
  41.     <li class="rsform-block rsform-block-radio4">
  42.         <div class="formCaption2">4. Do you limit your activities because of pain? Such as exercising, work or lifting?</div>
  43.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio40" value="2" name="form[radio4]"><label for="radio40">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio41" value="0" name="form[radio4]"><label for="radio41">No</label></div>
  44.         <div class="formDescription"></div>
  45.     </li>
  46.     <li class="rsform-block rsform-block-radio5">
  47.         <div class="formCaption2">5. Do you experience Pain, numbness or tingling in your arms or legs?</div>
  48.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio50" value="2" name="form[radio5]"><label for="radio50">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio51" value="0" name="form[radio5]"><label for="radio51">No</label></div>
  49.         <div class="formDescription"></div>
  50.     </li>
  51.     <li class="rsform-block rsform-block-radio6">
  52.         <div class="formCaption2">6. Do you use medications to relieve pain?</div>
  53.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio60" value="2" name="form[radio6]"><label for="radio60">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio61" value="0" name="form[radio6]"><label for="radio61">No</label></div>
  54.         <div class="formDescription"></div>
  55.     </li>
  56.     <li class="rsform-block rsform-block-radio7">
  57.         <div class="formCaption2">7. Can you tolerate pain without medications?</div>
  58.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio70" value="0" name="form[radio7]"><label for="radio70">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio71" value="2" name="form[radio7]"><label for="radio71">No</label></div>
  59.         <div class="formDescription"></div>
  60.     </li>
  61.     <li class="rsform-block rsform-block-radio8">
  62.         <div class="formCaption2">8. Does pain cause you to feel depressed, anxious, angry, or fatigued?</div>
  63.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio80" value="2" name="form[radio8]"><label for="radio80">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio81" value="0" name="form[radio8]"><label for="radio81">No</label></div>
  64.         <div class="formDescription"></div>
  65.     </li>
  66.     <li class="rsform-block rsform-block-radio9">
  67.         <div class="formCaption2">9. Have you discussed your pain with your doctor?</div>
  68.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio90" value="2" name="form[radio9]"><label for="radio90">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio91" value="0" name="form[radio9]"><label for="radio91">No</label></div>
  69.         <div class="formDescription"></div>
  70.     </li>
  71.     <li class="rsform-block rsform-block-calculate">
  72.         <div class="formCaption2"></div>
  73.         <div class="formBody"><button class="rsform-button" onclick="calculateRadio();" id="Calculate" name="form[Calculate]" type="button">Calculate</button><span class="formClr"></span></div>
  74.         <div class="formDescription"></div>
  75.     </li>
  76.     <li class="rsform-block rsform-block-total">
  77.         <div class="formCaption2">Pain Quiz Total</div>
  78.         <div class="formBody"><input type="text" class="rsform-input-box" id="Total" name="form[Total]" size="20" value=""></div>
  79.         <div class="formDescription"></div>
  80.     </li>
  81.     <li class="rsform-block rsform-block-thank-you">
  82.         <div class="formCaption2"></div>
  83.         <div class="formBody"><p>
  84. We understand that pain can take over your life no matter what the source. If you would like more information about managing pain or information on SEPC and the services we offer, please provide the information below. We respect your privacy and your information will be not be sold or used outside of SEPC.</p> <span class="formClr"></span></div>
  85.         <div class="formDescription"></div>
  86.     </li>
  87.     <li class="rsform-block rsform-block-first-name">
  88.         <div class="formCaption2">First Name</div>
  89.         <div class="formBody"><input type="text" class="rsform-input-box" id="First Name" name="form[First Name]" size="20" value=""><span class="formClr"><span class="formNoError" id="component38">This is a required field.</span></span></div>
  90.         <div class="formDescription"></div>
  91.     </li>
  92.     <li class="rsform-block rsform-block-last-name">
  93.         <div class="formCaption2">Last Name</div>
  94.         <div class="formBody"><input type="text" class="rsform-input-box" id="Last Name" name="form[Last Name]" size="20" value=""><span class="formClr"><span class="formNoError" id="component45">This is a required field.</span></span></div>
  95.         <div class="formDescription"></div>
  96.     </li>
  97.     <li class="rsform-block rsform-block-email">
  98.         <div class="formCaption2">Email</div>
  99.         <div class="formBody"><input type="text" class="rsform-input-box" id="Email" name="form[email]" size="20" value=""><span class="formClr"><span class="formNoError" id="component39">This is a required field.</span></span></div>
  100.         <div class="formDescription"></div>
  101.     </li>
  102.     <li class="rsform-block rsform-block-additionalinformation">
  103.         <div class="formCaption2"></div>
  104.         <div class="formBody"><input type="checkbox" style="margin: 0px 5px 0px 0px;" id="AdditionalInformation0" value="I am interested in receiving additional information about Southeast Pain Care and would like an email with my result. " name="form[AdditionalInformation][]" checked="checked"><label for="AdditionalInformation0">I am interested in receiving additional information about Southeast Pain Care and would like an email with my result. </label><span class="formClr"><span class="formNoError" id="component118">Invalid Input</span></span></div>
  105.         <div class="formDescription"></div>
  106.     </li>
  107.     <li class="rsform-block rsform-block-submit">
  108.         <div class="formCaption2"></div>
  109.         <div class="formBody"><input type="submit" class="rsform-submit-button" id="Submit" name="form[Submit]" value="Submit"><span class="formClr"></span></div>
  110.         <div class="formDescription"></div>
  111.     </li>
  112. </ol>
  113. </fieldset>
  114. <input type="hidden" value="3" name="form[formId]"></form>
  115.  
Nov 20 '12 #8
Dormilich
8,658 Recognized Expert Moderator Expert
it doesn’t matter if you call the variable total or score, just do it consistently.

one note on the HTML, you can put all the inline styling into a <style> section or CSS file, makes your HTML way better readable.

instead of document.write() you can use properties like textContent or innerHTML. it is even possible to have all three texts prepared, but hidden and you just display the appropriate one.
Nov 20 '12 #9
SEMKTG
11 New Member
Okay, so this is what I have for the javascript. If I use this (which still doesn't function), how do I get it to show up in the form where I want it to. I know I can control it with CSS, but the text area (either hidden or just empty, probably going to use an empty one) needs a variable as well. Does this script need to go on that element or on the form itself?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3.  
  4. var total = document.getElementByName('form[Total]');
  5. var score =0;
  6. var score =total.value;
  7. if( score <= 5 ){
  8.    document.textContent("<b>If you score 0-5</b>, you have minimal disability from pain but could be subject to worsening symptoms.");
  9. }else if( score < 12) {
  10.    document.textContent("<b>If you score 6-11</b>, pain may be affecting your quality of life. Don’t wait for it to take over your life. Talk to one of our double board certified physicians so they can determine what treatment plan will work best for your individual needs, using the least invasive methods possible &ndash; ultimately reducing the need for medication so you can return to your healthy, pain free lifestyle.");
  11. }else {
  12.   document.textContent("<b>If you score higher than 12</b>, the pain you are experiencing is out of the “normal” range, and the pain symptoms are interfering with your life. Pain can diminish job performance, lower motivation to exercise and prevent you from completing daily tasks, which causes some pain sufferers to get down on themselves or to view their chronic pain as a sign of weakness or a personal defect. Don't go down that road.");
  13. }
  14. //-->
  15.   </script>
Nov 20 '12 #10
SEMKTG
11 New Member
This is the form code I am using to test the script and I am not even getting a calculation from the question. Yes=2 No=0

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Untitled Document</title>
  6.   <script>
  7. function calculateRadio(){
  8.  
  9. var op9=document.getElementsByName('form[radio9]');
  10.  
  11. var result=document.getElementById('Total');
  12.  
  13. result.value=0;
  14.  
  15. result.value=parseInt(result.value);
  16.  
  17. for(i=0;i<op9.length;i++)
  18.  
  19. if(op9[i].checked) result.value=parseInt(result.value)+parseInt(op9[i].value);}
  20.  
  21. </script>
  22.  
  23. <script type="text/javascript">
  24. <!--
  25.  
  26. var total = document.getElementByName('form[Total]');
  27. var score =0;
  28. var score =total.value;
  29. if( score <= 5 ){
  30.    document.textContent("<b>If you score 0-5</b>, you have minimal disability from pain but could be subject to worsening symptoms.");
  31. }else if( score < 12) {
  32.    document.textContent("<b>If you score 6-11</b>, pain may be affecting your quality of life. Don’t wait for it to take over your life. Talk to one of our double board certified physicians so they can determine what treatment plan will work best for your individual needs, using the least invasive methods possible &ndash; ultimately reducing the need for medication so you can return to your healthy, pain free lifestyle.");
  33. }else {
  34.   document.textContent("<b>If you score higher than 12</b>, the pain you are experiencing is out of the “normal” range, and the pain symptoms are interfering with your life. Pain can diminish job performance, lower motivation to exercise and prevent you from completing daily tasks, which causes some pain sufferers to get down on themselves or to view their chronic pain as a sign of weakness or a personal defect. Don't go down that road.");
  35. }
  36. //-->
  37.   </script>
  38. </head>
  39.  
  40. <body>
  41. <div class="formBody">
  42. <form id="userForm">
  43. <li class="rsform-block rsform-block-radio9">
  44.         <div class="formCaption2">9. Have you discussed your pain with your doctor?</div>
  45.         <div class="formBody"><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio90" value="2" name="form[radio9]"><label for="radio90">Yes</label><input type="radio" style="margin: 0px 5px 0px 20px;" id="radio91" value="0" name="form[radio9]"><label for="radio91">No</label><span class="formClr"><span class="formNoError" id="component33">Invalid Input</span></span></div>
  46.         <div class="formDescription"></div>
  47.     </li>
  48.  
  49.   <input type="text" class="rsform-input-box" id="total" name="form[Total]" size="20" value="">
  50.   <span class="formClr"><span class="formNoError" id="component43">Invalid Input</span></span>
  51.   </form>
  52.  </div>
  53.  
  54.  
  55. <p>&nbsp; </p>
  56. <p><input name="Calculate" type="button" onClick="calculateRadio();" value="Calculate" /></p>
  57.  
  58.  
  59.  
  60.  
  61. </body>
  62. </html>
  63.  
  64.  
Nov 20 '12 #11
Dormilich
8,658 Recognized Expert Moderator Expert
textContent is a property of text-bearing HTML elements, not of the document (although it doesn’t cause an error, it doesn’t cause output either).

yet still, the output code runs before the user made his choice, so it would output the text on page load (and would not change afterwards).

and you should definitely see some messages in the Error Console.
Nov 20 '12 #12
SEMKTG
11 New Member
I don't understand what that means.
Nov 20 '12 #13
Dormilich
8,658 Recognized Expert Moderator Expert
what of the 3?
Nov 20 '12 #14
Rabbit
12,516 Recognized Expert Moderator MVP
It sounds like you're struggling with even the most basic JavaScript. It would probably do you some good to read a tutorial before trying to code. There's a good tutorial with online interpreter here: http://www.w3schools.com/js/default.asp.
Nov 20 '12 #15
SEMKTG
11 New Member
Instead of dcument.write, you stated to use textContent. I don't know where that goes. I understand the basics of javascript and can usually bend it to do what I want/need it to do. I am a designer tasked with this since the developer stated "getting a dynamic text area to show a particular snippit of data to show a different result depending on the content of a calculate box is " over his head"". That doesn't leave me with much.

I know when you state,
1. fill out form questions
2. hit calculate to get your score (this can't be a test since two of the questions have variables assigned to them without anything being correct or incorrect)
3. have an area just below the calculated results box show one of three results. 0-5, 6-11, higher than 12.

I also know there are about 50 different ways to write it up using javascript. But trying to piece things together from this tutorial and that tutorial is frustrating because they don't actually go through what I need to do.

If you can take a credit card payment, and are willing to get the code to work for the calculated total text box to show the associated results with a <p>content<a href>link</a></p>. Let me know what your rates are. The person who is supposedly heading this campaign up is so lacking they don't even take my knowledge base into consideration.

It's almost like... well you must be a master mechanic, you change your own oil...

So, if you can take a credit card payment; let me know what you would charge us for this and I will run it by our director.


Thanks,
Nov 20 '12 #16
Dormilich
8,658 Recognized Expert Moderator Expert
HTMLElement::textContent
assign text to a HTML element.
Expand|Select|Wrap|Line Numbers
  1. <p id="test">some text</p>
Expand|Select|Wrap|Line Numbers
  1. var p = document.getElementById("test");
  2. // assign new text
  3. p.textContent = "some new text";
  4. // add text
  5. p.textContent += " and some further text";
HTMLElement::innerHTML
works similar to textContent, only that the passed string is parsed for HTML code.

the comparison code

since the total value is calculated when the user presses the calculate-button, the comparison code (that has to work on the total value) must obviously (at least I thought that were obvious) also be put in the onclick handler function calculateRadio().
Nov 20 '12 #17
SEMKTG
11 New Member
I appreciate the feedback. It does help out a lot. I got the calculation button to calculate the question. Once clicked the "Sample Text" does switch out (which is leaps and bounds from where I started).

Only problem is the text that is shown when the button is clicked is the

"<b>If you score higher than 12</b>, the pain you are experiencing is out of the “normal” range, and the pain symptoms are interfering with your life. Pain can diminish job performance, lower motivation to exercise and prevent you from completing daily tasks, which causes some pain sufferers to get down on themselves or to view their chronic pain as a sign of weakness or a personal defect. Don't go down that road."

It doesn't matter what I do or what I change the variable to it either shows nothing or what is just above. It seems like the "if" statement isn't running and it's just going past all of the variables the the "else" statement that doesn't have any.

Thanks again for all of your help with this.

Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <div class="formBody">
  3.   <form id="userForm">
  4.     <li class="rsform-block rsform-block-radio9">
  5.       <div class="formCaption2">9. Have you discussed your pain with your doctor?</div>
  6.       <div class="formBody">
  7.         <input type="radio" style="margin: 0px 5px 0px 20px;" id="radio90" value="2" name="form[radio9]">
  8.         <label for="radio90">Yes</label>
  9.         <input type="radio" style="margin: 0px 5px 0px 20px;" id="radio91" value="0" name="form[radio9]">
  10.         <label for="radio91">No</label>
  11.         <span class="formClr"><span class="formNoError" id="component132">Invalid Input</span></span></div>
  12.       <div class="formDescription"></div>
  13.     </li>
  14.     <li class="rsform-block rsform-block-total">
  15.       <div class="formCaption2">Pain Quiz Total</div>
  16.       <div class="formBody">
  17.         <input type="text" class="rsform-input-box" id="Total" name="form[Total]" size="20" value="">
  18.         <span class="formClr"><span class="formNoError" id="component134">Invalid Input</span></span></div>
  19.       <div class="formDescription"></div>
  20.     </li>
  21.     <button class="rsform-button" onclick="calculateRadio();" id="Calculate" name="form[Calculate]" type="button">Calculate</button>
  22.     <p id="test">Sample Text</p>
  23.   </form>
  24.   <script>
  25. function calculateRadio()
  26. {
  27.     var op9=document.getElementsByName('form[radio9]');
  28.     var result=document.getElementById('Total');
  29.  
  30.     result.value="0";
  31.     result.value=parseInt(result.value);
  32.     for(i=0;i<op9.length;i++)
  33.     if(op9[i].checked) result.value=parseInt(result.value)+parseInt(op9[i].value);
  34.  
  35.  
  36.  
  37.     var p = document.getElementById("test");
  38.     var total=document.getElementById('Total');
  39.     if (total <= 5) {
  40.         // show first text
  41.         p.textContent="<b>If you score 0-5</b>, you have minimal disability from pain but could be subject to worsening symptoms.";
  42.     }
  43.     else if (total ==6 && total <= 12) {
  44.         // show second text
  45.         p.textContent="<b>If you score 6-11</b>, pain may be affecting your quality of life. Don’t wait for it to take over your life. Talk to one of our double board certified physicians so they can determine what treatment plan will work best for your individual needs, using the least invasive methods possible &ndash; ultimately reducing the need for medication so you can return to your healthy, pain free lifestyle.";
  46.     }
  47.     else {
  48.         // show third text
  49.         p.textContent="<b>If you score higher than 12</b>, the pain you are experiencing is out of the “normal” range, and the pain symptoms are interfering with your life. Pain can diminish job performance, lower motivation to exercise and prevent you from completing daily tasks, which causes some pain sufferers to get down on themselves or to view their chronic pain as a sign of weakness or a personal defect. Don't go down that road.";
  50.     }
  51. document.getElementById("Total").innerHTML=total;
  52.  
  53. }
  54. </script> 
  55. </div>
  56. </body>
  57.  
Nov 20 '12 #18
Dormilich
8,658 Recognized Expert Moderator Expert
I don’t know how many time I have to repeat it, but the else if() part needs only one condition (cf. post #7). and currently the else if() will only trigger, if total = 6.

you might also have missed that textContent only inserts text, but not HTML code.
Nov 21 '12 #19
SEMKTG
11 New Member
Thanks for the help. I finally got it. One of the variables was wrong so it wasn't pulling the calculated total to show the correct results. I also got the links to work as well, and it's not to buggy.
Nov 27 '12 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sumGirl | last post by:
Can someone demonstrate a SIMPLE way to do this that does not require additional functions or stored procedures to be created? Lets say I want to execute the following simple query - "select * from...
4
by: michael | last post by:
I have an html text string within a div, eg.: <div id="example">Text text text</div> I know its easy to change styles by using getElementById - for example: ...
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
4
by: Stu | last post by:
Hi, I am writing a content management system that has to have W3C compliant output. The pages are template driven and there are special strings within the template to be used as placeholders for...
2
by: TCook | last post by:
Hello All, I need to try to programmatically and dynamically populate some lists on a web page. I wanted to know the best advised way to pass the information to the web page. For example,...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
0
by: mcnews | last post by:
is there any way to use something like sendkeys to auto-populate text boxes on an existing web page? assuming i can assemble the correct data can i use a sendkey type of function to tab through...
1
by: pskvenkat | last post by:
Hi this is venkat, I am Using Asp.net (C#) . Can you give me the details for how to store the dynamically created text box value into sql server database. pls give me a code if any?
1
by: adarshyam | last post by:
can anybody tel me how to clear values from dynamically created text boxes?? using a clear button.. this is the code used to create dynamic text boxes.. if i press clear button then it must clear all...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.