ExXxTaSy,
<html>
<head>
<title></title>
<script>
var price1 = 10, price2 = 20, price3 = 30;
function conversion(val) {
if (isNaN(val)) { }
else {
document.getElementById("div").innerHTML = val < 10 ? val*price1 : ((val > 10 && val < 50) ? val*price2 : (val > 50 ? val*price3 : ""));
}
}
</script>
</head>
<body>
<input type="text" onBlur="conversion(this.value)" onChange="conversion(this.value)" onkeypress="conversion(this.value)">
<div id="div"></div>
</body>
</html>
|