Pages: [1]   Go Down
Author Topic: Need help understanding html forms  (Read 516 times)
0 Members and 1 Guest are viewing this topic.
Buena Vista, CO
Offline Offline
Full Member
***
Karma: 0
Posts: 184
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 hodgers-house.com

* testserver.zip (2.29 KB - downloaded 2 times.)
Logged

8000ft above the average

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 147
Posts: 6040
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try something like this. All buttons in a group must share the same name.
Code:
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.
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12205
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:

Code:
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? ]
Logged

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

Pages: [1]   Go Up
Jump to: