Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: help : submit with javascript problem

Rick Reumann

2004-10-10

Replies:

Michael McGrady wrote the following on 10/10/2004 10:09 PM:

> I do wonder in this case, however, whether you use buttons or rely on
> the auto-gui, why use "button" rather than "submit", if you want to
> submit? I might also say, that is what submit buttons are for. I
> assume, however, that there is a reason to use <input type='button'>
> rather than <input type='submit'> and would like to understand that. I
> have an old prejudice against JavaScript which may be partly
> irrational.

Actually I'm pretty sure using an html submit button would work as well
for handling onClick events that don't actually submit a form. Using the
html button though seems to make sense though just so that the page
author can see that's it's not actually being used to submit a form.

For example on this last application I worked on one of the requirements
was that the client wanted buttons signify something you can 'do' versus
having html links. So for example maybe you were on a page that
displayed a list of employees and next to each employee there would be a
button "edit employee" - this would be a case where we used html buttons
that had an onClick handler that went to a new url. (there were a few
other buttons also on the page). So for example a line might look like...

<c:url var="url" scope="page" value="/editEmployee.do">
  <c:param name="dispatch" value="setUp"/>
  <c:param name="associateID" value="${associate.associateID}"/>
</c:url>
<input type="button" onClick="goLink('${url}');" value="<fmt:message
key='label.edit'/>

//also may be buttons for "summary" "logs" etc on each row
You really wouldn't want a form to surround the whole employees list
since each button is sumbitting to a totally a different action

You could also use the <button ...> tag. ( I believe you have more html
styling controlling using <button > although I've found <input
type="button" suitable for my needs. )

By the way, a great site for all the HTML and CSS properties:

html http://www.blooberry.com/indexdot/html/tagindex/all.htm
css http://www.blooberry.com/indexdot/css/propindex/all.htm

--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.