数字转换

<body onload="s()">
<input id="num_input" value="99995960" />
<span id="num_span"></span>
</body>
<script>
function s(){
var num_input = document.getElementById("num_input");
var num_span = document.getElementById("num_span");
var input_value = eval(num_input.value);

    var num_span_int=parseInt(input_value);
    if(num_span_int>10000){
        var fist=parseInt(num_span_int/10000);
        var second=parseInt(num_span_int%10000);
        var second_i=parseInt(second/100);

num_span.innerText=fist+"."+second_i+"";
            }
    else{ num_span.innerText=input_value;} }
</script>

 

posted @ 2015-11-18 16:13  djdliu  阅读(139)  评论(0编辑  收藏  举报