| Author | 
         | 
         
      
        
         
         traviskleckner Senior Member 
          
  
  Joined: February 26 2007 Location: United States
 Online Status: Offline Posts: 118
          | 
        
         
          
           | Posted: December 08 2008 at 15:19 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
I'm trying to create a web page that can be passed a 
 device name and then integrate that device name into 
 forms, links, and lastly show the status of the device.
 
 I've got the links and form working...but can't nail 
 down the status.  The section in red below is what 
 doesn't work.  I'm guessing that my problem is that the 
 <% tags are not letting the inside run.  I don't know 
 enough Java to really debug well though.  Thoughts?
 
 Here is what I have:
 
 <script  type="text/JavaScript"    Language="Java Script">
          var params = 
 document.location.search.substr(1,document.location.sear
 ch.length).split('&');
          var arguments = Array();
          for(var i=0;i<params.length;i++) {
               var arg = params.split("=");
               arguments[arg[0]] = arg[1];
          }
 
             var myForm = document.TestForm;
             myForm.id.value = arguments['device'];
             myForm.NextURL.value = 
 arguments['back'];
 
             var  TestVar = 
 document.getElementById("LinkOnTest");
             TestVar.href = "/ph-cgi/evalformula?
 formula=ph_insteon('" + arguments['device'] + 
 "',iOn,255)&nexturl=" + arguments['back'];
             
             TestVar = 
 document.getElementById("LinkOffTest");
             TestVar.href = "/ph-cgi/evalformula?
 formula=ph_insteon('" + arguments['device'] + 
 "',iOff,0)&nexturl=" + arguments['back'];
 
             var pageTitle = 
 document.getElementById("pageTitle");
         pageTitle.innerHTML = arguments['device'] || "";
 
             TestVar = 
 document.getElementById("Level");
             TestVar.src = "<% 
 if(ph_getinsteonlevel('" + arguments['device'> + 
 "')=0,'off.gif', if(ph_getinsteonlevel('" + 
 arguments['device'> + "')>245,'on.gif','dim.gif')) %>";
 
 
      </script>
 
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: December 08 2008 at 20:05 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Maybe the forum is killing your code, but you are missing closing brackets for the arguments bits.
 
 
Code: 
   
    
    
      
       | TestVar.src = "<% if( ph_getinsteonlevel( '" + arguments['device']> + "')=0,'off.gif', if(ph_getinsteonlevel('" + arguments['device']> + "')>245,'on.gif','dim.gif')) %>"; | 
       
       | 
    
    | 
 
 
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: December 08 2008 at 20:10 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Wait, I don't think that will work either.
 
 The file is parsed when it's served. Your "arguments" reference doesn't mean anything at that point.
 
 Unless there is code that passes that back which you took out for your post...
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         traviskleckner Senior Member 
          
  
  Joined: February 26 2007 Location: United States
 Online Status: Offline Posts: 118
          | 
        
         
          
           | Posted: December 08 2008 at 22:36 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Forum killed my code.  There are closing brackets.  The 
 formula works perfectly if cut and pasted into PH.  I 
 can take the <% %> off and drop that into text and it's 
 a formula that works perfect.
 
 I think your second message is on target.  It's an order 
 of execution.  The Java is running on the client, and of 
 course PH is serving that page beforehand.
 
 My question becomes...is there anyway to get returns 
 from a formula in Java?
 
 My goal is to make a page that can be called from 
 anywhere to set the levels on a light.  I've got a page 
 with 2-3 lights for the room in a table like this:
 
 Name (on/off/dim pic)   ON  +10%  -10%  Off
 
 My goal is to make a link so you can do off/on from the 
 page, but to click the name and set to any level.
 
 I'd *love* to have the page look up the status on it's 
 own, but if that doesn't work I might just pass it as a 
 parameter to that page.  It's not quite as dynamic, but 
 it's something I could live with.
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: December 09 2008 at 07:48 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
My lighting page reads the status on load using ph_getinsteonlevel and ph_getx10level.
 
 Here is the thread. It's more complicated than what you need due to the sliders, but I think you can get some good info from it.
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   |