> If you search the archives of this list, you'll find
> some more
> discussion of using submit buttons with run modes.
> As you noticed they
> often don't work directly. Jesse had a simple
> solution for this, which I
> have adopted. If the submit buttons can't set the
> run mode directly, and
> a direct hidden field doesn't work, some simple
> JavaScript can be used
> to fill the gap. Because the JavaScript is very
> basic, it's easy to
> implement and widely compatible. Here's a real-world
> example:
>
> function item_edit () {
> document.item_form.rm.value="item_edit";
> }
> function item_suggest_add () {
>
> document.item_form.rm.value="item_suggest_add";
> }
> function item_delete () {
> if (confirm('Really Delete?')) {
>
> document.item_form.rm.value="item_delete";
> return true;
> } else {
> return false;
> }
> }
>
> This can help for a few reasons
> * The form can submit to multiple run modes from a
> single form
> * The run modes aren't tied to the language on the
> button, allowing the "design"
> of the run mode name to changed without affecting
> the code. This would
> be a
> significant feature if someone wanted to translate
> your app into another
> language.
>
> To make the above work, the remaining details are:
>
> * Have the form named "item_form", or otherwise
> match your JavaScript
> * include an empty "rm" hidden field:
> <input type="hidden" name="rm" value="">
> * Call the function through a method such as
> "onClick":
> <INPUT TYPE="submit" NAME="action" VALUE="delete"
> onClick="item_delete()">
>
> Sometimes I skip using the functions and just
> include the JavaScript
> directly in the button, like this:
> <input type="submit" name="submit" value="Add"
>
onClick="document.item_form.rm.value='item_suggest_add';">
>
> I use this scheme and really like it.
Thanks Mark! Back before the holidays Jesse also
suggested using Javascript, on the basis that it would
be better if images were ever used as submit buttons.
It all makes sense and I plan on looking into it soon.
The Javascript is trivial as noted, and anyway I'm
closer to being a Javascript guru than CGI/Perl.
> Just for fun,
> below is my setup
> routine from Cascade.
Thanks for this as well, and your spirit of sharing!
=====
George M. Jempty
Database Admin/Intranet Architect
Regional West Medical Center
Scottsbluff, Nebraska
[EMAIL PROTECTED][EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]