Shop OBEX P1 Docs P2 Docs Learn Events
PINK program help — Parallax Forums

PINK program help

PaulPaul Posts: 263
edited 2007-06-21 22:24 in BASIC Stamp
Hello, How do I get the PINK variable <NB_var01> into a JavaScript variable? I'm sure its simple but I have little experience in programming in HTML or JavaScript.
I've tried the following without success:

1. var·myvalue = document.getElementsByName('NB_var01').value; //undefined

2. window.status = <NB_var01>;· //errors out

Thanks, any help will be appreciated.

Paul

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-21 16:38
    Paul,

    I have contacted the developer of the firmware to see if this is supported and how. I will post what I find. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • PaulPaul Posts: 263
    edited 2007-05-22 12:38
    Problem solved! I put the first·five·<Nb_var0x> variables into a HTML Table. From there I could manipulate the variables using the ID of the table and the 'innerHTLM' javascript statement. Works like a charm! Thanks for your help Chris. Now on to the BS2 side of the·programs.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <script type="text/javascript">
    function load()
      {
      var myVal=document.getElementById('myTable').cells
      alert(myVal[noparse][[/noparse]2].innerHTML)              //shows Nb_var02 value
      }
    </script>
    </head>
    <body onload="load()">
    <table id="myTable" border="0"  width="10px">
      <tr><!-- Row 1 -->
         <td><Nb_var00></td>
         <td><Nb_var01></td>
         <td><Nb_var02></td>
         <td><Nb_var03></td>
         <td><Nb_var04></td>
      </tr>
    </table>
    </body>
    </html>
    
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-22 14:30
    Paul,

    Thanks for sharing your success. This could help others in the future. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-20 19:29
    Paul,

    I decided to do a little playing around myself since one of my test applications is a remote security station. In order for it to work I need the web page to refresh every 5 seconds (very easy to do) and update the information on the page. But more importantly I need to detect when a variable is set to a certain value and cause the page to redirect. I am doing this with JavaScript and this required me to figure out how to get the variable into a JS variable. Please see the attached snippet from my PINK test page. I hope this helps someone out. Take care.
    <script type="text/javascript">
    var d="<Nb_var00>"
    document.writeln(d)
    if (d==="SEARCH") 
    {
    window.location = "[url=http://www.google.com/]http://www.google.com/[/url]"
    }
    </script>
    
    

    The above example jumps to Google when the variable <Nb_var00> changes to the word SEARCH. ·Note that this is exactly what I am using but it should get the point across.· Note also that you don't need the document.writeln section...I was using that to debug the variable information.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support


    Post Edited (Chris Savage (Parallax)) : 6/20/2007 7:34:25 PM GMT
  • PaulPaul Posts: 263
    edited 2007-06-21 19:50
    I see what you did there. Quoted the variable. Nice. A lot easier than building tables. Thanks for the update.

    Paul
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-21 22:24
    Paul,

    Doing it that way let’s you bring it right into the JavaScript variable…Nice and easy. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-21 22:24
    Paul,

    Doing it that way let’s you bring it right into the JavaScript variable…Nice and easy. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.