I have a HTML form with a field
<input type='text' name="HR" id="HR" onblur="totalSum(this);"/>
I am trying to get this value in the javascript file as follows
function totalSum(obj)
{
var HR=document.getElementById("HR").value;
}
suppose I am trying to enter 150 in the HR field, then it is not able to fetch it in the HR variable in the javascript file. Could you please guide me where am I going wrong.
as suggested by @crayon I am trying to do something like this .. thanks for your reply. I am trying to do something like this........
if(parseInt(HR)>=100 && parseInt(HR)<150)
{
sum1=0;
}
else if(parseInt(HR)>= 150 || parseInt(HR)<= 100)
{
sum1=1;
}
else if(parseInt(HR)>= 180 || parseInt(HR)<= 90)
{
sum1=2;
}
else if(parseInt(HR)>= 190 || parseInt(HR)<= 80)
{
sum1=4;
}
and i changed onkeypress to onblur, but still its not working ...
Code for using sum1.
document.getElementById('Total').value = parseInt(sum1)+parseInt(sum3)+parseInt(sum5)+parseInt(sum6)+parseInt(sum7);
type="VARCHAR(45)"Um, what?