long time reader, first time poster. I'm currently doing my first home automation project and have things running well at the moment. What I'm having trouble with is the following. You'll see from the first code below that I have a number of submit button with different values. These values post to an arduino that activate the corresponding channel (via I2C) to turn relays on/off.
<?php include('inc.header.php'); ?>
<link rel="stylesheet" href="lcars.css">
<html>
<head>
<title>Pool/Alfresco</title>
<body style="background-color:powderblue;">
<form action="http://192.168.2.110/control" target="dummyframe" method="POST">
<h1 style="text-align:center;">Pool/Alfresco Controls</h1>
<div style="float:right;width:40%;">
<img src="img/pool1.gif"><img src="img/pool2.gif"><img src="img/pool3.gif"><img src="img/pool4.gif"><img src="img/pool5.gif"><img src="img/pool6.gif">
</div>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="On" value="11"> Spa Light
</div>
<br><br>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="On" value="12"> Pool Light
</div>
<br><br>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="On" value="13"> Tree Light
</div>
<br><br>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="On" value="14"> Fountains
</div>
<br><br>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="On" value="16"> Spa
</div>
<br><br>
<div style="float:left;width:20%;">
<input class="lcarsbutton" style="color:#f90;height:5%;width:55%;" type="submit" name="AllOff" value="0"> Disable All
</div>
</form>
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
</body>
</html>
<?php include('inc.footer.php'); ?>
This is pretty simple code however I'd like to be able to achieve the same by using the following code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Pool Controls</title>
<link rel="stylesheet" href="style2.css">
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#button').on('click', function(){
$(this).toggleClass('on');
});
});
</script>
</head>
<body>
<h1 style="text-align:center;color:red">Pool/Alfresco Controls</h1>
<section>
<a href="#" id="button"></a>
<span></span>
</section>
</body>
</html>
This code renders a nice looking "Power" button that toggles a light below it between red/green (for off/on states). So basically I need to be able to submit the values in the first code to the arduino to toggle the channels on/off.
I can't post images yet so here's a link to what I mean.
http://media02.hongkiat.com/css3-on-off-button/post-cover.jpg
Any help would be greatly appreciated. Thanks in advance.