PINK / Javascript question
Tumbler
Posts: 323
Hello
The html page below is my pink index page.
As you can see, it shows 4 switches, and are clickable. (on or off)
When you click one of these, the vars are set to true or false. (images too)
It works, but my page flickers when i click one.
Is there a proper way to do this? I'm not a javascript expert...
index.html
Post Edited By Moderator (Bean (Hitt Consulting)) : 11/3/2009 7:31:45 PM GMT
The html page below is my pink index page.
As you can see, it shows 4 switches, and are clickable. (on or off)
When you click one of these, the vars are set to true or false. (images too)
It works, but my page flickers when i click one.
Is there a proper way to do this? I'm not a javascript expert...
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]"> <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml[/url]"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #333; } --> </style> <script language="javascript"> var xmlRequest; function SetDefault(id) { //var varname = document.getElementById("variable_name").value; if(id=='00'){ var newval =<Nb_var00> != true; } else if(id=='01'){ var newval = <Nb_var01> != true; } else if(id=='02'){ var newval = <Nb_var02> != true; } else if(id=='03'){ var newval = <Nb_var03> != true; } var msg = 'variable_name='+id+'&NewVal=' + newval; HttpReqPost(msg); } function HttpReqPost(sendtext) { var URL; URL = "VALUESET.HTM "; xmlRequest = getXMLHttpRequest(); xmlRequest.open("post", URL); //xmlRequest.setRequestHeader("variable", ""); xmlRequest.setRequestHeader("Content-Type", "text/xml"); //xmlRequest.setRequestHeader("Connection", "close"); xmlRequest.onreadystatechange = processReqChange; xmlRequest.send(sendtext); } function getXMLHttpRequest() { if (window.XMLHttpRequest) { return new window.XMLHttpRequest; }else{ try { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); } catch(ex) { alert("No http request capability"); return null; } } } function processReqChange() { if (xmlRequest.readyState == 4) { if (xmlRequest.status == 200) { window.location="index.html"; }else{ alert("There was a problem sending the XML data:\n" + xmlRequest.status + " " + xmlRequest.statusText); } } } </script> </head> <body> <img name="in1" src="[url=http://www.tumbler.be/SmartLogicImages/images/Sensor_%3CNb_var00%3E.jpg]http://www.tumbler.be/SmartLogicImages/images/Sensor_<Nb_var00>.jpg[/url]" onclick="return SetDefault('00')" /> <img name="in2" src="[url=http://www.tumbler.be/SmartLogicImages/images/Sensor_%3CNb_var01%3E.jpg]http://www.tumbler.be/SmartLogicImages/images/Sensor_<Nb_var01>.jpg[/url]" onclick="return SetDefault('01')" /> <img name="in3" src="[url=http://www.tumbler.be/SmartLogicImages/images/Sensor_%3CNb_var02%3E.jpg]http://www.tumbler.be/SmartLogicImages/images/Sensor_<Nb_var02>.jpg[/url]" onclick="return SetDefault('02')" /> <img name="in4" src="[url=http://www.tumbler.be/SmartLogicImages/images/Sensor_%3CNb_var03%3E.jpg]http://www.tumbler.be/SmartLogicImages/images/Sensor_<Nb_var03>.jpg[/url]" onclick="return SetDefault('03')" /> </body> </html>
Post Edited By Moderator (Bean (Hitt Consulting)) : 11/3/2009 7:31:45 PM GMT
Comments