我有这个代码,我希望为访问我页面的任何人创建可能性,如果选中了复选框,我想与我的Raspberry Pi进行通信,其中.html页面将托管在[Pi将会是人们将连接并访问HTML页面的访问点]。我该怎么办?我必须在if语句的if语句下添加什么代码,以及您推荐哪些方式进行通信?
<img src="http://i.imgur.com/59fHyah.png" id="checkbox" width="40" style="margin: 3.55cm 5.04cm"/>
<img src="http://i.imgur.com/59fHyah.png" id="checkbox_1" width="40" style="margin: 3.55cm -0.70cm"/>
<img src="http://i.imgur.com/59fHyah.png" id="checkbox_2" width="40" style="margin: 1.65cm -0.44cm"/>
<script>
var checkbox = document.getElementById('checkbox');
var checkbox_1 = document.getElementById('checkbox_1');
var checkbox_2 = document.getElementById('checkbox_2');
var img_1 = 'http://i.imgur.com/59fHyah.png';
var img_2 = 'http://i.imgur.com/zgwd1n1.png';
var img_3 = 'http://i.imgur.com/Mi1DQpC.png';
checkbox.onclick = function () {
if (checkbox.src == img_1) {
checkbox.src = img_2;
} else if (checkbox.src == img_2) {
checkbox.src = img_3;
} else if (checkbox.src == img_3) {
checkbox.src = img_1;
}
}
checkbox_1.onclick = function () {
if (checkbox_1.src == img_1) {
checkbox_1.src = img_2;
} else if (checkbox_1.src == img_2) {
checkbox_1.src = img_3;
} else if (checkbox_1.src == img_3) {
checkbox_1.src = img_1;
}
}
checkbox_2.onclick = function () {
if (checkbox_2.src == img_1) {
checkbox_2.src = img_2;
} else if (checkbox_2.src == img_2) {
checkbox_2.src = img_3;
} else if (checkbox_2.src == img_3) {
checkbox_2.src = img_1;
}
}
</script>
<style>
body {
background-image: url("http://i.imgur.com/kcmsgdr.png");
background-repeat: no-repeat;
background-color: #cccccc;
}
</style>