struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hardee, Tony" <Tony.Har...@ps.net>
Subject RE: Default Button
Date Thu, 09 May 2002 12:10:08 GMT

I have a tag that generates java script.  Below is the relevant code from
the tag

            out.println("");
            out.println("<!-- Map Enter Key - BEGIN -->");
            out.println("<SCRIPT LANGUAGE=\"JavaScript\">");
            out.println("<!--");
            out.println("  function getKey(keyStroke) {");
            out.println("    isNetscape=(document.layers);");
            out.println("    eventChooser = (isNetscape) ? keyStroke.which :
event.keyCode;");
=>>>        out.println("    if (eventChooser == 13) {");
            out.println("      window.location=\"" + location + "\";");
            out.println("    }");
            out.println("  }");
            out.println("  document.onkeypress = getKey;");
            out.println("-->");
            out.println("</script>");
            out.println("<!-- Map Enter Key - END -->");
            out.println("");

To use the code/tag in the jsp I simply type

	<ccom:MapEnterKey location="javascript:submitForm()"/>

The line preceded with =>>> maps the enter key.  The location in the tag can
be any uri or in the above example, the submit of the form.  Instead of
using a tag you could just inline the javascript in your page.

Hope this helps.

Tony

-----Original Message-----
From: Rich Reese [mailto:ReeseR@firsttrust.com]
Sent: Tuesday, May 07, 2002 11:18 AM
To: struts-user@jakarta.apache.org
Subject: Default Button


How do you make a submit button a default button on a JSP, so when the user
hits the 'Enter' key the button is submitted?  I think it has something to
do with the accesskey attribute, but I do not know what value to assign to
it.

Any suggestions are appreciated,
Rich


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message