Go Down

Topic: Need help understanding html forms (Read 589 times) previous topic - next topic

alfiesty

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
8000ft above the average

SurferTim

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

MarkT

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

Code: [Select]
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 ]

Go Up