[ciapug] Form submission

Tim Perdue ciapug@cialug.org
Thu, 09 Sep 2004 12:00:49 -0500


Jerry Weida wrote:

> This generally occurs when the submit button is not of the type
> submit.  You can either change that to a submit type or your can write
> some javascript.
> can't remember how to get the keycode into the fuction, but I'm sure
> you can find that out somewhere online pretty easy, or maybe someone
> here on the list would know.
> some pseudo-code
> 
> <input type="button" onChange="javascript:submitform()" />
> 
> function submitform() {
>   if btn=chr(13)   # see if we hit the enter key
>     document.forms[0].submit()
> }

I've had this happen when I do use the type="submit", and on the 
receiving end, my php is looking for "if ($submit) {"

Since submit was never pressed, the if statement doesn't work out to true.

So you can get around it by having an <input type="hidden" name="foo" 
value="1"> and then on the receiving end you do "if ($foo) "

And it works out to true whether they hit submit button or not.

Tim