Jump to content

Recommended Posts

Ok so I did some homework and I figured out most of my previous issue, now I am down to a little problem that I am having issues with. I am using the code:

<script type="text/javascript">
function updateTotal(){
var total = 0;
for(var i=1; i<10; i++){
 if(!isNaN(jQuery('#txt'+i).val())){
  total = (parseInt(total) + parseInt(jQuery('#txt'+i).val()));
 }
}
jQuery('#total').html(total);
if (total <= 6 ) {
document.write("<p>Congratulations, you are getting enough sleep!");
} else if (total == 7 || total ==  {
document.write("<p>Your score is average</p>");
} else {
document.write("<p>Seek the advice of a sleep specialist without delay</p>");
}
}
</script>
<script>
$(document).ready(function() {
$('form input:text').change(function() {
      $('#total').val(this.value).text(total);
   });
}); // end ready
</script>

 

and the image posted is the output. I need it to add up all the numbers in the text fields and spit them out. Right now it only wants to write that its a <span> tag.

post-134159-0-15651000-1354393682_thumb.jpg

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.