CodeIgniter Forums
Missing Javascript Function?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Missing Javascript Function?? (/showthread.php?tid=53077)



Missing Javascript Function?? - El Forum - 07-10-2012

[eluser]dhall[/eluser]
I am passing the following code from my Controller to my View:

Code:
$data['hrzone_button'] = array (
     'name' => 'hrzones',
     'type' => 'button',
     'class' => 'next',
     'value' => 'Calculate Heart Rate Zones',
     'onclick' => 'hrzones();'
   );

In my View I have the button to call the function:

Code:
echo form_submit($hrzone_button).br(2);

And at the bottom of my View I have the function:

Code:
[removed]  
function hrzones()
{
  var a = document.getElementById('fthr');  
  var b = document.getElementById('mhr');  
  var c = document.getElementById('hr1_min');
  c.value = parseInt(a.value) + parseInt(b.value);
}  
[removed]

When I run the page and click on the button nothing happens. I checked for an error in Firebug and it says this:

"hrzones is not a function"

What am I missing? I am sure it is something silly.
Thanks for the help!