[Javascript] Re: one form, two submit ways
Matthew Palmer
mpalmer at hezmatt.org
Thu Feb 17 06:15:03 CST 2005
On Thu, Feb 17, 2005 at 01:12:13PM +0100, Michael Borchers wrote:
> > On Thu, Feb 17, 2005 at 12:32:31PM +0100, Michael Borchers wrote:
> > > <form action="script.php" name="form>
> > > ...
> > > some inputs
> > > ...
> > >
> > > <select name="subaction">
> > > option book
> > > option print
> > >
> > > submit ???
> > >
> > > </form>
> > >
> > >
> > > the subaction later decides what to do with the data.
> > >
> > > now i would like to leave out the select for subaction
> > > and offer two submit buttons with "book" and "print"
> > > but with the same effect.
> >
> > Assuming that subaction is processed on the server, I'd presume that
> >
> > <input type="submit" name="subaction" value="book">
> > <input type="submit" name="subaction" value="print">
> >
> > Would do the job. If subaction is processed in an onChange
> > or onSubmit
> > handler, then you can just keep the same basic code and just
> > add onClick
> > handlers to your two submit buttons.
> >
> > - Matt
>
>
> this works perfectely.
> the only "prob" i have is my php script now.
> f.e. when it asks for subaction's value it has to be "book" or "print",
> the words that appear on the buttons.
> but in a different language like german "buchen", "drucken"
> it would no longer work.
Not officially, but I've had some success in an onClick handler to rewrite
the values to their canonical forms on form submission, like so:
<input type="submit" name="subaction" value="buchen"
onClick="document.form.subaction.value='book'">
<input type="submit" name="subaction" value="drucken"
onClick="document.form.subaction.value='print'">
But I haven't tested that *particular* code I just gave, so take it with a
grain or two of salt.
- Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050217/122c3708/attachment.pgp>
More information about the Javascript
mailing list