这真让我抓狂。我无法弄清楚为什么我会收到“mytest is not defined”错误:
这是小提琴-> 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);
}