Go Down

Topic: A bit lost - onchange event (Read 785 times) previous topic - next topic

Chaz7201

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



Nadir

Your question is related with Arduino? 

AlphaBeta

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!

Go Up