开发者

javascript analogue gauge im trying to drive with live values

I have a JavaScript analogue gauge I'm trying to drive with live values elsewhere on the page that is dynamically updated. I want to display this value on the gauge.js. Below is what I have, minus the form/post vals i would like to use. I suspect the highlighted lines 开发者_开发知识库below are not correctly formatted?

Thanks for the help cody

<script type="text/javascript">
         function getReg(){
                 var regVal29 = document.getElementById('reg1029');
         }
    </script>   
*************************

dc_amperage = new Gauge( document.getElementById( 'dc_amperage' ), {label:     "DCAmperage"});

            **dc_amperage.setValue(parseInt(var regVal29.value 10););**


Modify getReg to the following:

function getReg() {
    var reg_elem = document.getElementById('reg1029');
    if (!reg_elem) {
        throw new Error('No element found');
    }
    return reg_elem.value;
}

Then in your setValue use:

try {
    dc_amperage.setValue(parseInt(getReg(), 10));
} catch (err) {
    //error handle
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜