Go Down

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


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


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.


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 will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131