$(document).ready(function() { var globalSum = 150; var price = 0; var page_val = 0; $("#page_count").keyup(function () { page_val = $("#page_count").attr("value") * 30; $("#result").attr("value", globalSum+parseFloat(page_val)); }); });