开发者

javascript analogue gauge im trying to drive with live values

开发者 https://www.devze.com 2023-03-31 18:57 出处:网络
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 th

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

精彩评论

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