Pages: [1]   Go Down
Author Topic: A bit lost - onchange event  (Read 731 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am by no means a programer, I however can get most things to work via - java,html,php and such usually by searching the web. My project im working on now is trying to get some data from a webpage as a user inputs it.

to do this i am trying to get a slider bar to send a number to a tcp/ip port when the change occurs.
Ive seen and searched up alot about the onChange event of sliderbars. nowhere can i find clean simple code with just a sliderbar doing this function.

I understand a few things i need to do with my page.
first, when the page is loaded i need to open a socket with the arduino so it resets. ( im actualy transfering data via ust/serial, tcpip is only emulated.)
second i need to keep this connection open till the page is closed.

If anyone has any info on what language might get this idea done i would be so great-full.

here is some code i was working with.

<html> /// simple html code for making a slider
<body>
<input type="range" min="0" max="180" value="0" step="1" onchange="showValue(this.value)" />
<span id="range">0</span>
<script type="text/javascript">
function showValue(newValue)
{
   document.getElementById("range").innerHTML=newValue;
}
</script>
</body>
</html>

where the "showValue(this.value)" is, might i put something else there to open the socket?

perhaps call php

</PHP
$sock_data = socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); 
$sock_data = socket_write($sock, "HTML VAR", strlen("HTML VAR"));
?>

do i need to creat a php function that i call and send the var from the html?

lol, ANY HELP would be sweetness. THANKS


Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your question is related with Arduino? 
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, you will need a php running on your webserver.

I would do as you say, a javascript that calls the php whenever you change the value of the range. You should do it asynchronously, have a look at jQuery post and ajax methods.

Good luck!
Logged

Pages: [1]   Go Up
Jump to: