Shop OBEX P1 Docs P2 Docs Learn Events
Set PINK default value within a user web page — Parallax Forums

Set PINK default value within a user web page

Ron CzapalaRon Czapala Posts: 2,418
edited 2009-09-22 17:09 in BASIC Stamp
I created a web page which uses an xmlHttpRequest allowing you set a Default value in the PINK module.
It posts to the built-in DEFAULTSET.HTM to effect the change.
NOTE: You will have to enter the name and password just like when you use the VV_show.htm page to update variables.

You enter the variable name or number (e.g. ET, 00-19 ...) and the new default value and click the button to set the default.
<html>
<head>
<title></title>
<script language="javascript">
var xmlRequest; function SetDefault() {
  var varname = document.getElementById("variable_name").value;
  var newval = document.getElementById("NewVal").value;
  var msg = 'variable_name=' + varname + '&NewVal=' + newval;
  HttpReqPost(msg);
}
function HttpReqPost(sendtext) {
  var URL;
  URL = "DEFAULTSET.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) {
//    alert(xmlRequest.responseText);   //    ...processing statements go here...
//    respval.innerText = xmlRequest.responseText; 
    }else{
      alert("There was a problem sending the XML data:\n" +
            xmlRequest.status + " " + xmlRequest.statusText);
    }        
  }
}
</script>
</head>
  <IMG src="images\parallax-web-server.jpg" width="519" height="73">
  <br>
  Enter variable name/num (ET, ES..., 00 - 19) <input id=variable_name name=variable_name value="" sise=2>
  <br>
  Enter new value <INPUT id="NewVal" NAME="NewVal" TYPE="text" SIZE="64" VALUE="">
  <br>
  <INPUT type="button" value="Set Default" id=button1 name=button1 onclick="return SetDefault()">
</BODY>
</HTML>


Post Edited (ronczap) : 9/21/2009 8:13:20 PM GMT

Comments

  • xanatosxanatos Posts: 1,120
    edited 2009-09-22 00:05
    OOOooohhh! This could be VERY helpful - thanks VERY much - and for PMing me!

    Dave
  • dev/nulldev/null Posts: 381
    edited 2009-09-22 08:02
    Very nice ronczap!!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-22 17:09
    Very clever work-around for setting defaults outside the Modify Variables page.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
Sign In or Register to comment.