RE: [phplib] Oohforms and submit buttons From: Taylor, Stewart (Stewart.Taylor <email protected>)
Date: 06/14/01

In my applications I point all my forms to the same action page index.php.

index.php consists of a switch statement, something like

switch ($action) {
case "updateRecord":
   include "act_updaterecord.php";
   break;
case "findRecord":
   include "act_findrecord.php";
   break;
case "displayRecord":
   include "dsp_displayrecord.php";
   break;
default:
   include "dsp_main.php";
   break;
}

Then in my form I have a hidden field named action.

$f->ae("type"=>"hidden",
       "name"=>"action"));

When a submit button is clicked I set action to the relevant value.
e.g.
$f->ae("type"=>"submit",
       "name"=>"Update",
       "value"=>"Update",
       "extrahtml"=>"onclick=\"action.value='updateRecord'\""

If my form has only one text field - as in your case - I initialise the
value of action to the relevant value.

e.g.
$f->ae("type"=>"hidden",
       "name"=>"action",
       "value"=>"findRecord"));

$f->ae("type"=>"text",
       "name"=>"Find",
       "value"=>""));

-Stewart.

-----Original Message-----
From: Jesse Swensen [mailto:swensenj <email protected>]
Sent: 14 June 2001 15:12
To: Paul Smith; phplib <email protected>
Subject: Re: [phplib] Oohforms and submit buttons

You could use JavaScript to set the value for you.

First in you header define what setSubmit does like
<script>
    function setSubmit() {
        document.MyForm.Mysubmit.value = "Submitted";
    }
</script>

In your form declaration you would put something like

<form name="MyForm" onSubmit="setSubmit()">
. . .
    <input type="hidden" name="MySubmit" value="">
</form>

This is a very rough suggestion and you will need to flesh it out. YMMV...

-- 
Jesse Swensen
swensenj <email protected>

> From: Paul Smith <paul <email protected>> > Date: Tue, 12 Jun 2001 15:51:01 -0500 > To: phplib <email protected> > Subject: [phplib] Oohforms and submit buttons > > If you're using oohforms, one way to set things up is to have the form > action be $PHPSELF, then check for the existence of the submit button > to do error checking. However, if there is only one <input type="text"> > element in a form, and you hit return within that element to submit the > form, the submit button doesn't get passed to the action page. You have > to click it with the mouse. > > Is there a better way to do this? How can you check that a form has been > submitted without relying on the submit button? > > -- > Paul Smith <paul <email protected>> > InfoTech Designer > Center for Neighborhood Technology > Chicago, Illinois USA > > --------------------------------------------------------------------- > To unsubscribe, e-mail: phplib-unsubscribe <email protected> > For additional commands, e-mail: phplib-help <email protected> >

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>