[mdlug] [HTML Tech Suppor] How to direct input type text to particular input type submit

list1c30fe42 at bellsouth.net list1c30fe42 at bellsouth.net
Tue Nov 24 19:18:56 EST 2009


Webbers,

Summary:
How can one determine the action performed when typing return
in a <input type=text ...> field
within an html form
with more than one <input type=submit ...> field?

Workaround:
Switching the order of submit fields changes firefox behavior.

Workaround limitation:
This does not work in most browsers,
and may not work in all firefox situations.



Detail:
I'm wikimaster for my employer using MoinMoin.

The default search (when you type return in the search text field
is s title-only search (not a full content text search) per MoinMoin 
design (see form below).

Our employers want default text search behavior (similar to google).

The MoinMoin website indicates that this is a well-worn debate,
that has been decided in favor of title searches by default.

I have observed that firefox apparently responds to typing return in
input type=text field by submitting the first input type=sumbit field.
Consequently, I have switched the order of the submit fields (as
indicated below).



---- the form in question (__init__.py) ----
...
     def searchform(self, d):
         """
         assemble HTML code for the search forms

         @param d: parameter dictionary
         @rtype: unicode
         @return: search form html
         """
         _ = self.request.getText
         form = self.request.form
         updates = {
             'search_label': _('Search:'),
             'search_value': wikiutil.escape(form.get('value', [''])[0], 1),
             'search_full_label': _('Text'),
             'search_title_label': _('Titles'),
             'baseurl': self.request.getScriptname(),
             'pagename_quoted': 
wikiutil.quoteWikinameURL(d['page'].page_name),
             }
         d.update(updates)
...
<form id="searchform" method="get" action="%(baseurl)s/%(pagename_quoted)s">
<div>
<input type="hidden" name="action" value="fullsearch">
<input type="hidden" name="context" value="180">
<label for="searchinput">%(search_label)s</label>
<input id="searchinput" type="text" name="value" 
value="%(search_value)s" size="20"
     onfocus="searchFocus(this)" onblur="searchBlur(this)"
     onkeyup="searchChange(this)" onchange="searchChange(this)"
     alt="Search">
<input id="titlesearch" name="titlesearch" type="submit"
     value="%(search_title_label)s" alt="Search Titles">
<input id="fullsearch" name="fullsearch" type="submit"
     value="%(search_full_label)s" alt="Search Full Text">
</div>
</form>
...
---- the form in question (__init__.py) ----

---- form change ----
- <input id="titlesearch" name="titlesearch" type="submit"
-     value="%(search_title_label)s" alt="Search Titles">
   <input id="fullsearch" name="fullsearch" type="submit"
       value="%(search_full_label)s" alt="Search Full Text">
+ <input id="titlesearch" name="titlesearch" type="submit"
+     value="%(search_title_label)s" alt="Search Titles">
---- form change ----

TIA,
--
Bob



More information about the mdlug mailing list