Vintage radio [Image courtesy of sippakorn at FreeDigitalPhotos.net]Vintage radio [Image courtesy of sippakorn at FreeDigitalPhotos.net]Image courtesy of sippakorn at FreeDigitalPhotos.net

An ex-boss (bless his little cotton socks) once wanted me to implement some code that submitted a form when the user changed the selection in a set of radio buttons.

In this post:
  1. Just no
  2. Solution

1. Just no

This seemed fairly simple: surely I could just do something like:

<form method="GET" action="mypage.php">
    <input type="radio" name="dateselect" id="today" onclick="submit();" value="today" />
    <input type="submit" name="submit" value="Submit Selection" />
</form>

After writing a separate function and calling it on the onclick() method, and after trying different syntax to refer to the form, and after reading countless forums on how to get this right…

2. Solution

Solution: rename your submit button — or even (as JavaScript is case-sensitive) — call your button Submit.

I mean: which idiot calls their submit button “submit” anyway?

By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from stylus

Subscribe now to keep reading and get access to the full archive.

Continue reading