Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8026

Other programming languages • Any HTML + JavaScript wizards ?

$
0
0
I am trying to get my Pi Pico to serve a web page which allows the browser to tell the Pico what the PC's local time is. That's basically working ...

Code:

<html>  <body>    <form id='sync' method='get' action='/='>      <button type ='submit'>Synchronise Time</button>    </form>    <script type='text/javascript'>      d = new Date();      document.getElementById('sync').action += d.valueOf();    </script>  </body></html>
And when I click the "Synchronise Time" button my Pico sees an appropriate request ...

Code:

GET /=1709192331665? HTTP/1.1
That unsurprisingly appears to be the time when the page was loaded and what I'd like is the time at the point the button is clicked.

For a 'bonus hero point' - How, because I can't get it to work other than above, to wrangle the 'action' so I can receive ...

Code:

GET /?sync=1709192331665 HTTP/1.1
It's been over two decades since I've done any real HTML or JavaScript so if anyone can provide the answer I'd be grateful. Results via Google have been about as useful as from a Chat AI.

Statistics: Posted by hippy — Thu Feb 29, 2024 7:55 am



Viewing all articles
Browse latest Browse all 8026

Trending Articles