AW: [Javascript] Re: one form, two submit ways

Kim Hoogenberg kim.hoogenberg at virgil.nl
Thu Mar 3 07:17:58 CST 2005


why don't you just use something like:

<input type="button" name="book" value="Book!" 
onclick="document.forms['bookForm'].submit()">
<input type="button" name="print" value="Print!" onclick="document.forms
['printForm'].submit()">

Or

<input type="hidden" name="subaction" value="">
<input type="button" name="book" value="Book!" 
onclick="document.forms['form'].subaction.value='book';document.forms
['form'].submit()">
<input type="button" name="print" value="Print!" onclick="document.forms
['form'].subaction.value='print';document.forms['form'].submit()">

Hope this helps.

Greetz,

Kim

----- Original Message -----
From: Michael Borchers <borchers at tridem.de>
Date: Thursday, March 3, 2005 12:39 pm
Subject: AW: [Javascript] Re: one form, two submit ways

> > > > > <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
> >
> 
> i tried to parse 2 inputs named "action" or "delete"
> but they won't work. this must be because
> "action" is mentioned already in the <form> tag
> and "delete" is one of javascript's reserved words.
> 
> are there any "typical" names for vars that are parsed in the URL,
> something common a lot of programmers "should" use?
> I liked the "action" tag:(
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 




More information about the Javascript mailing list