Pete Wilson : Consultant Software Engineer

Lowell MA   978.454.4547   pete at pwilson dot net    April 2008

 Home/Resume  
 Sample code 
 Experimental 
 CGI notes 
 CSS notes 
 Standards 
 Books 

Workarounds

Let each reset button clear just one text-input control

We can give the user several submit buttons in a single form. But every reset button in the form clears every text-input control.

What if we don't like this risky feature? What if we want each of several reset buttons, say, to refer to just one input field?

Here's one workaround that seems to work in some browsers, though it doesn't validate. We'll place forms within a form, each inner form having one text-input control and one reset button (and perhaps also its own submit button/buttons). Maybe something like this:

<form method="post" action="/cgi-bin/cgi-inp">
 <form action="">
  <input type="reset" value="reset 1" />
  <input type="text" name="line_1" value="" />
 </form>
 <form action="">
  <input type="reset" value="reset 2" />
  <input type="text" name="line_2" value="" />
 </form>
 <input type="submit" value="submit both" />
</form>