无法在JSP中显示期望值 [英] Unable to display expected value in jsp

查看:63
本文介绍了无法在JSP中显示期望值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i在javascript中将值四舍五入为.25,.50,.75和.00.代码如下.

i was rounding off the value to .25,.50,.75 and .00 in the javascript. and the code is as below.

function roundOff(obj) {
    //alert(document.getElementById("sample").value);
    var val=obj.value;
    var newValue;

    var floorValue = Math.floor(val);
    var remainder = val - floorValue;
    if (remainder < 0.325) {
        if (remainder < 0.125) {
            newValue = floorValue;

        } else {
            newValue = floorValue + 0.25;
        }
    } else {
        if (remainder < 0.625) {
            newValue = floorValue + 0.5;
        } else if (remainder < 0.875) {
            newValue = floorValue + 0.75;
        } else {
            newValue = floorValue + 1;
        }
    }
    alert(floorValue);

        alert(newValue);
        document.getElementById("sample").value=newValue;

    //return obj;
}

,但是无法将值放回jsp页面.如果我输入5.5,则jsp中仅显示5.但是,如果我发出警报并检查floorvalue的值,则为5.5.但是如果我将它放在jsp的文本框中,它只给出5.为什么会这样?

but am not able to put the value back to the jsp page. if i type 5.5, only 5 is displayed in the jsp. but if i put alert and check the value of floorvalue then it is 5.5. but if i put it to the textbox in jsp it is giving only 5. why is it so???

推荐答案

我在jsp中使用了onKeyUp,这引起了麻烦.相反,我将其更改为onBlur,因为它提供了与我的要求相同的效果.谢谢"nnnnnn"的建议.现在可以正常工作了.

I was using onKeyUp in the jsp which was causing the trouble. instead i changed it to onBlur as it was providing the same effect as per my requirement. And thank you 'nnnnnn' for your suggestion. Its working now.

这篇关于无法在JSP中显示期望值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆