Stop running this script, IE7 using PHP

Posted by Jomel Dicen on Stack Overflow See other posts from Stack Overflow or by Jomel Dicen
Published on 2012-06-21T03:06:51Z Indexed on 2012/06/21 3:16 UTC
Read the original article Hit count: 180

Filed under:

I incorporate javascript in my PHP program: Try to check my codes.

It loops depend on the number of records in database. for instance:

$counter = 0;
foreach($row_value as $data):
   echo $this->javascript($counter, $data->exrate, $data->tab);
endforeach;

private function javascript($counter=NULL, $exrate=NULL, $tab=NULL){

$js = "
<script type='text/javascript'>
$(function () {
  var textBox0 = $('input:text[id$=quantity{$counter}]').keyup(foo);
  var textBox1 = $('input:text[id$=mc{$counter}]').keyup(foo);  
  var textBox2 = $('input:text[id$=lc{$counter}]').keyup(foo);

  function foo() {                      
   var value0 = textBox0.val();
   var value1 = textBox1.val(); 
   var value2 = textBox2.val();
   var sum = add(value1, value2) * (value0 * {$exrate});
   $('input:text[id$=result{$counter}]').val(parseFloat(sum).toFixed(2));

   // Compute Total Quantity
   var qtotal  = 0;
   $('.quantity{$tab}').each(function() {
    qtotal += Number($(this).val());
   });
   $('#tquantity{$tab}').text(qtotal);

   // Compute MC UNIT
   var mctotal  = 0;
   $('.mc{$tab}').each(function() {
    mctotal += Number($(this).val());
   });
   $('#tmc{$tab}').text(mctotal);

   // Compute LC UNIT
   var lctotal  = 0;
   $('.lc{$tab}').each(function() {
    lctotal += Number($(this).val());
   });
   $('#tlc{$tab}').text(lctotal);

    // Compute Result
    var result  = 0;
    $('.result{$tab}').each(function() {
     result += Number($(this).val());
    });
    $('#tresult{$tab}').text(result);
   }

   function add() { 
    var sum = 0;    
    for (var i = 0, j = arguments.length; i < j; i++) { 
      if (IsNumeric(arguments[i])) {    
       sum += parseFloat(arguments[i]); 
      } 
    }   
    return sum; 
   }

   function IsNumeric(input) {  
     return (input - 0) == input && input.length > 0;   
   }            

  });
 </script>
";
 return $js;

}

When I running this on IE this message is always annoying me " Stop running this script?

A script on this page is causing your web browser to run slowly. If it continues to run, your computer might become unresponsive."

but in firefox it's functioning well.

© Stack Overflow or respective owner

Related posts about JavaScript