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

Michael Borchers borchers at tridem.de
Thu Mar 3 05:39:52 CST 2005


> > > > <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:(



More information about the Javascript mailing list