You are here: When does the html input type submit get set? « PHP Programming Language « IT news, forums, messages
When does the html input type submit get set?

Posted by Taras_96 on 10/05/59 11:38

Hi everyone,

I've got a rather unconventional architecture that I'm having problems
with...

I have a form called "searchForm", that has an input of type "submit"
(with name = "submitButton for argument sake). What happens when the
form is submitted (when the submit button is clicked...) depends on
some previous user input. In one case, the onsubmit handler calls a
function that does basic input checking, and returns true if all the
inputs are correct, and thus submits the form:

onsubmit = "return submitSearchForm"

In the other case, the onsubmit handler calls some java functions that
accomplish some other functionality, and the java functions themselves
call submit on the form:

onsubmit = "doStuff(); return false;"

function doStuff()
{
//..do some other complicate stuff
document.getElementById('searchForm').submit()
}

In the latter case, the form seems to get submitted, because the page
reloads. Also, the $_POST variables that the form submits are set.
However, in the latter case, the $_POST['submitButton'] variable is not
set, even though the form was submitted by clicking on the submit
button! In the prior case, the $_POST['submitButton'] is set.Why is
this the case? Does it have something to do with the fact that the form
was submitted by a function, rather than the onsubmit handler?

Are there any elegant workarounds to this problem (I use the
$_POST['submitButton'] value to check if the form has been submitted -
if it has, I do some processing on the form's inputs)?. One way I can
think of is having a hidden input called 'formSubmitted' which is
initially set to false, and prior to calling submit() on the form, you
set this input to true, and you can test to see if this value is true
in addition to testing if $_POST['submitButton'] is set:

if ( isset($_POST['submitButton']) || formSubmitted == 'true')
{
//.. do some form processing
}

Any help would be appreciated!

Cheers

Taras

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация