Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <!-- Script by Your Mother
- 14.03.2014
- -->
- <script type="text/javascript"> <!--
- var xhttp;
- var url_on = "http://jimpachnet.de/pi/on.php";
- var url_off = "http://jimpachnet.de/pi/off.php";
- var checkboxname = "onoff";
- function createXMLHttpRequest() {
- if (window.ActiveXObject) {
- try {
- // IE 6 and higher
- xhttp = new ActiveXObject("MSXML2.XMLHTTP");
- } catch (e) {
- try {
- // IE 5
- xhttp = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- xhttp=false;
- }
- }
- }
- else if (window.XMLHttpRequest) {
- try {
- // Mozilla, Opera, Safari ...
- xhttp = new XMLHttpRequest();
- } catch (e) {
- xhttp=false;
- }
- }
- }
- function sendRequest_on() {
- if (!xhttp) {
- //alert("An Error occured when trying to initialize XMLHttpRequest!");
- return; // exit
- }
- alert("On");
- xhttp.open("GET",url_on,true);
- xhttp.onreadystatechange=sendRequest_callback;
- xhttp.send(null);
- }
- function sendRequest_off() {
- if (!xhttp) {
- //alert("An Error occured when trying to initialize XMLHttpRequest!");
- return; // exit
- }
- alert("Off");
- xhttp.open("GET",url_off,true);
- xhttp.onreadystatechange=sendRequest_callback;
- xhttp.send(null);
- }
- function sendRequest_callback() {
- //alert ( xhttp.readyState);
- if (xhttp.readyState==4 && xhttp.status==200){
- // alert ( xhttp.responseText );
- }
- }
- function init() {
- createXMLHttpRequest();
- }
- window.onload=init;
- function sendrightrequest(){
- if(document.getElementsByName(checkboxname)[0].checked){
- sendRequest_on();
- }else{
- sendRequest_off();
- }
- }
- // --> </script> </head> <body>
- <form method="get" action="<?php echo basename(__FILE__);?>">
- <p><h4>Schalte die coolste LED der Welt, nämlich meine!<h4></p>
- <input type="checkbox" name="onoff" value="on" onchange="javascript:sendrightrequest();"> AN/AUS<br>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement