Re: multiple submit buttons
| From: | Miles Thompson | Date: | Thu, 30 Nov 2000 03:39:39 +0000 |
| Subject: | Re: multiple submit buttons | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27965@lists.php.net to get a copy of this message | ||
Not necessarily, you can do this ...
Assign values to the variables holding the button value, e.g. $Add="Add", but
it could be $Add="Ajoutez!"
Define your buttons in the form this way:
<input type = \"submit\" name = \"action[]\" value= \" $Add \" >
<input type = \"reset\" name = \"action[]\" value= \" $Clear \"
>
<input type = \"submit\" name = \"action[]\" value= \" $Cancel \"
>
<input type = \"submit\" name = \"action[]\" value= \" $Update \"
>
And then process actions they trigger this way:
if( isset( $action[0] ) )
{
switch( $action[0] )
{
case "$Add":
echo "Add User";
ChkUsernameUnique()
ChkEmptyFields()
ChkEmailOK()
ChkPhoneOK()
// Appropriate message
break;
case "$Clear":
// no need to do anything
break;
case "$Cancel":
//code goes here
break;
case "$Update":
echo "Update User";
ChkEmptyFields()
ChkEmailOK()
ChkPhoneOK()
// set message / prepare SQL
break;
}
}
$Add through $Update are assigned values before the form definition, and the
case's following the switch() statement just check for content. You can
substitute any text at any time, even change languages. Try it.
Regards - Miles Thompson
Sebastian Delmont wrote:
> That works too... but then your code is dependent on the words you want to
> show in the button...
>
> I rather use different names for different buttons and simply check for the
> existence of the variable.
>
> Regards,
> Sebastian
>
> "Daniel Convissor" <danielc@analysisandsolutions.com> wrote in message
> news:3A24907C.94494E84@analysisandsolutions.com...
> > Hi Deepak:
> >
> > > > From: Deepak Chawla [mailto:dchawla@usa.unl.edu]
> > > >
> > > > I need two submit buttons in a html form, and i need them to do two
> > > > different things...eg: a text box for a filename and two submit
> buttons,
> > > > one for opening the file and another for deleting it.
> >
> > FORM:
> > <input type="submit" name="Something" value="Open"
> > />
> > <input type="submit" name="Something" value="Delete"
> > />
> >
> >
> > SCRIPT:
> > switch ($Something) {
> > case "Open":
> > fopen(........);
> > break;
> >
> > case "Delete":
> > unlink(.......);
> > break;
> >
> > }
> >
> >
> > Enjoy,
> >
> > --Dan
> >
> > --
> > PHP scripts that make your job easier
> > http://www.analysisandsolutions.com/code/
> > SQL Solution | Layout Solution | Form Solution
> > T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
> > 4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net