Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Using <% %> with Java... Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
traviskleckner
Senior Member
Senior Member
Avatar

Joined: February 26 2007
Location: United States
Online Status: Offline
Posts: 118
Posted: December 08 2008 at 15:19 | IP Logged Quote traviskleckner

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 View traviskleckner's Profile Search for other posts by traviskleckner
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 08 2008 at 20:05 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 08 2008 at 20:10 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
traviskleckner
Senior Member
Senior Member
Avatar

Joined: February 26 2007
Location: United States
Online Status: Offline
Posts: 118
Posted: December 08 2008 at 22:36 | IP Logged Quote traviskleckner

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 View traviskleckner's Profile Search for other posts by traviskleckner
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 09 2008 at 07:48 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum