0

This is driving me crazy. I cannot figure out why I get "mytest is not defined" error:

here's the fiddle --> http://jsfiddle.net/y7MTs/5/

HTML:

<span>One: </span>
  <input type='text' id='ax' value='4' size='6'/>
  <br/>

<span>Two: </span>
  <input type='text' id='bx' value='2.5' size='6'/>
  <br/><br/>

<button onclick='mytest(ax.value, bx.value);'>Go Now</button>

Javascript:

function mytest(a, b) {
  var x = [0, 1, 2, 3, 4, 5];
  var y = [100, 120, 140, 160, 180, 200];

  var myval = parseFloat(a) - x[3];
  alert(myval);    

}
0

1 Answer 1

7

In your fiddle, the function is in the scope of a callback which is given to the onload event handler.

In the menu at top left, choose no wrap - in <head>.

Fixed fiddle : http://jsfiddle.net/dystroy/FrVE6/

Sign up to request clarification or add additional context in comments.

1 Comment

Wow! Thanks! WTF... I've never used that before and never had this issue

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.