0
The code at the end of the statement is OK and works as expected.
On the lines
<a href='?f=on' onclick="alert('LiGHT ON')" class='btn1 btn-sea'>ON</a>
<a href='?f=off' onclick="alert('LiGHT OFF')" class='btn2 btn-sea'>OFF</a>
The expression: href='?f=xxx'
passes the parameter that is needed for the system to work. This means that there are 2 buttons, one for each different parameter value.
I would like to do the same thing though, using only one button to perform one event at a time. Something like the button toggle.
It is also important to maintain the use of HTML/CSS/Javascript and not use links or calls to external routines, as this code will be embedded.
<!DOCTYPE HTML>
<html>
<head>
<meta charset='UTF-8'>
<meta http-equiv='cache-control' content='max-age=0' />
<meta http-equiv='cache-control' content='no-cache' />
<meta http-equiv='expires' content='0' />
<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
<meta http-equiv='pragma' content='no-cache' />
<title>automation</title>
<style>
body {font-family: Helvetica; color: rgb(85,85,85);} /* backgroud color */
h1 {font-size: 24px; font-weight: normal; margin: 0.4em 0;}
.container {width: 100%; margin: 0 auto;}
.container .row {float: left; clear: both; width: 100%;}
.container .col {float: left; margin: 0 0 1.2em; padding-right: 1.2em; padding-left: 1.2em;}
.container .col.twelve {width: 100%;}
@media screen and (min-width: 200px) {
.container {width: 50%; max-width: 1080px; margin: 0 auto;}
.container .row {width: 100%; float: left; clear: both;}
.container .col {float: left; margin: 0 0 1em; padding-right: .5em; padding-left: .5em;}
.container .col.four {width: 50%;}
.container .col.tweleve {width: 100%;}}
* {-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}
a {text-decoration: none;}
.btn1 {font-size: 20px;
white-space: nowrap;
width: 100%;
padding: .8em 1.5em;
font-family: Helvetica;
line-height: 20px;
display: inline-block;
zoom: 1;
color: rgb(255,255,255);
text-align: center;
position:relative;
-webkit-transition: border .25s linear, color .25s linear, background-color .25s linear;
transition: border .25s linear, color .25s linear, background-color .25s linear;}
.btn1.btn-sea{background-color: rgb(15,219,0); border-color: rgb(10,145,0); -webkit-box-shadow: 0 3px 0 rgb(10,145,0); box-shadow: 0 3px 0 rgb(10,145,0);}
.btn1.btn-sea: hover{background-color: rgb(10,145,0);}
.btn1.btn-sea: active{top: 3px; outline: none; -webkit-box-shadow: none; box-shadow: none;}
.btn2 {font-size: 20px;
white-space: nowrap;
width: 100%;
padding: .8em 1.5em;
font-family: Helvetica;
line-height: 20px;
display: inline-block;
zoom: 1;
color: rgb(255,255,255);
text-align: center;
position:relative;
-webkit-transition: border .25s linear, color .25s linear, background-color .25s linear;
transition: border .25s linear, color .25s linear, background-color .25s linear;}
.btn2.btn-sea{background-color: rgb(255,42,42); border-color: rgb(204,0,0); -webkit-box-shadow: 0 3px 0 rgb(204,0,0); box-shadow: 0 3px 0 rgb(204,0,0);}
.btn2.btn-sea: hover{background-color: rgb(204,0,0;}
.btn2.btn-sea: active{top: 3px; outline: none; -webkit-box-shadow: none; box-shadow: none;}
</style>
</head>
<body>
<div class='container'>
<div class='row'>
<div class='col twelve'>
<p align='center'>
<font size='10'>REMOTE CONTROL</font>
</p>
</div> </div>
<div class='row'>
<div class='col four'>
<a href='?f=on' onclick="alert('LiGHT ON')" class='btn1 btn-sea'>ON</a>
</div>
<div class='col four'>
<a href='?f=off' onclick="alert('LiGHT OFF')" class='btn2 btn-sea'>OFF</a>
</div> </div>
<div class='col twelve'> </div> </div>
</body>
</html>
thanks for the corrections Daniel.
– songa
You’ll need at least Javascript for this. Only with HTML and CSS you won’t be able to do it. What do you mean "do not use links or calls to external routines"? Will this page be embedded on some device and can’t request other files? That’s it?
– Woss
@Andersoncarloswoss, thank you very much for your feedback... ok, we can use javascript too, but it has to be part of the body of the program. Yes, it cannot use external assistance, so I need a solution that is complete in the same code.
– songa
And what should be the starting button? On or * Off*? The information if the page will be embedded on any device may be important to this problem. It will?
– Woss
@Andersoncarloswoss, thank you again... I answered earlier... there must have been some delay in seeing my answer... the answer is YES, will be shipped... It can be initially on OFF... thank you very much.
– songa
Last question: what does this parameter interfere with? The page will be served by a code in C that will check the value of the parameter by turning the lamp on or off?
– Woss
@Andersoncarloswoss, you can ask as many questions as you think you need... YES, the code discussed here, will be implemented in a C routine, to be a web server and when the code returns, the parameter in question, will serve for the routine in C to determine the new status of the lamp... as I explained before, the code I put here, works perfectly, just wish it were used a boot and not 2 as it is currently.
– songa