Announcement

Collapse
No announcement yet.

JavaScript and ASP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    JavaScript and ASP

    I'm trying to use a script that has sliders to control some homeseer devices.

    How can I insert a DeviceString into a javascript and how do I run a Homeseer function from a javascript?

    To give you an example of what I'm trying to do, I have a Denon amp that reports it's volume setting in a virtual device. When I run an asp page that controls this I use hs.DeviceString("v8") which returns the present value of the volume control. To change the volume I use the command
    s = hs.RunEx("denon.vbs","send","MVUP") and then recall the page with a response.redirect statement, and the page comes up with the new value. This works but is akward, so I wanted to use a slider, but that is in javascript.

    Any suggestions?

    Thanks;
    Don

    #2
    Well, half way there. I discovered that putting an ASP variable into javascript is no big thing. For those who are curious...

    Going the other way looks like it will be daunting...Perhaps a redirect to another page and back...
    PHP Code:
     <%
     
    volume =  CStr(hs.DeviceString("v8"))
     %>
     
     <
    script type="text/javascript">
     
     var 
    = new Slider(document.getElementById("slider-1"), document.getElementById("slider-input-1"));
     var 
    s2 = new Slider(document.getElementById("slider-2"), document.getElementById("slider-input-2"), "vertical");
     
    s.onchange = function () {
         
    document.getElementById("h-value").value s.getValue();
         
    document.getElementById("h-min").value s.getMinimum();
         
    document.getElementById("h-max").value s.getMaximum();
         
    s2.setValue(s.getValue());
         
    s2.setMinimum(s.getMinimum());
         
    s2.setMaximum(s.getMaximum());
     };
     
    //Get Value from HomeSeer and insert it into javascript
     
    s.setValue(<%= volume %>);
     
    window.onresize = function () {
         
    s.recalculate();
     };
     
    //window.location ="/ir.asp";
     
    </script
    Don

    Comment

    Working...
    X