из того, что я понимаю, вам нужно выбрать значение вашего текстового поля, но вам также понадобится функция, которая будет нажата при нажатии клавиши и передает значение вашего текстового поля в Calculate () функция
используйте эту функцию, которая будет выполняться после нажатия клавиши.
$("#yourtextboxidhere").keyup(function(){
var textValue = $.trim( $('#yourtextboxidhere').val() );
// convert the string value from text box to int so you can use it in your calculate function for comparison
// as text box values are string)
var textValue = parseInt(textValue)
//Put your calculate function here and pass it the value:
calculate(textValue);
//calculate function goes here.... (don't forget to add a parameter in you calculate function so you may use it in a correct way)
//replace 'i' in your function with the passed parameter.
});
не забудьте использовать jquery.