Jump to content

jquery help .. execute function


everisk

Recommended Posts

Hi

 

I'm a jquery newbie. I'm trying to sum a column with below code on page load. it works fine. But I also want to update the total when the input changes. How do I do that? I dont even know how to specify a function in jquery  :confused:

 

Basically, something like <input type="text" name="whatever" id="whatever" class="regular" onBlur="runJqueryFunction()" />

 

$(document).ready(
function() {
	var total=0;
	$('.regular').each(
		function() {
			total = parseInt(total) + parseInt(this.value);
		}
	);
$('#total_regular').text(total);
}
);

Link to comment
https://forums.phpfreaks.com/topic/182270-jquery-help-execute-function/
Share on other sites

<script type="text/javascript">

function totalIt() {
      var total=0;
      $('.regular').each(
         function() {
            total = parseInt(total) + parseInt(this.value);
         }
      );
   $('#total_regular').text(total);
   } 

$('.regular').blur(totalIt);
</script>

Archived

This topic is now archived and is closed to further replies.

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