Pages: [1]   Go Down
Author Topic: Need help understanding html forms  (Read 527 times)
0 Members and 1 Guest are viewing this topic.
Buena Vista, CO
Offline Offline
Full Member
Karma: 0
Posts: 190
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to switch things (currently a led) from a web page. Thanks to zoomkat, I am well along. I could switch the led on/off with a ext field, now I am trying radio buttons. There are two problems
1) you seem to be able to have two buttons clicked at once
2) nothing gets back to the server
I am creating the buttons thusly
          client.write("<form>Led Off <input type=radio name=t value=Led Off>");
          client.write("Led On <input type=radio name=r value=Led On></form>");
The ino is much too big so I am attaching it as a zip
To see the page go to

* (2.29 KB - downloaded 3 times.)

8000ft above the average

Miramar Beach, Florida
Offline Offline
Faraday Member
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try something like this. All buttons in a group must share the same name.
client.write("<form>Led Off <input type=radio name=led value=off>");
 client.write("Led On <input type=radio name=led value=on></form>");
Retrieve variable led on the server. It will be set to on or off.

Offline Offline
Shannon Member
Karma: 214
Posts: 12406
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd use the full syntax, to be HTML / XHTML agnostic, and be explicit about action and method:

client.write("<form method='...' action='...'>Led Off <input type='radio' name='led' value='off' />");
 client.write("Led On <input type='radio' name='led' value='on' /></form>");

IIRC a form without an action attribute will behave differently on different browsers.

[edit:  Oh, and where's the submit button? ]

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: