html - Which button was pressed? -


i know question has been asked before, cannot seem find reasonable answer circumstances.

i have form multiple buttons in submit , required know button pressed.

a small code snippet of inside of form may this:

<input type="submit" name="action" value="<fmt:message key="id001"/>"/> <!-- save -->   <input type="submit" name="action" value="<fmt:message key="id002"/>"/> <!-- delete -->  <input type="submit" name="action" value="<fmt:message key="id003"/>"/> <!-- other action --> 

the fmt:message part takes consideration language of client , places word on button.

until now, adding action handler on submit buttons , adding hidden input element onto form telling me 1 pressed, need support site without depending on javascript.

since values of buttons variable, how can approach this? (essentially can if input had place value="" , text="", doesn't)

i thought moving "values" want such "save" , "delete" name attribute, , checking whether or not value set doing following:

<c:if test="${!empty param.save}"> . . . </c:if> 

however, problem arises when have,say list of x size can each deleted. i'll give example of mean:

form jsp:

<input type="submit" name="delete_row|1" value="<fmt:message key="id001"/>"/> <!-- delete first row-->   <input type="submit" name="delete_row|2" value="<fmt:message key="id002"/>"/> <!-- deleted second row -->  <input type="submit" name="delete_row|3" value="<fmt:message key="id003"/>"/> <!-- delete third row --> ... 

server side jsp:

<c:if test="${!empty param.delete_row|x}">  . . <%-- handle specific row deletion here--%> . </c:if> 

^- have no idea x going be... can 1, or 100 or more, need way find param starts delete_row , delimit somehow.

i've looked little , found <button> element, not supported in versions of ie (ie<8 far can remember?).

so, restrictions are:

  • no js
  • must supported browsers old ie6 or preferably more

anyone have suggestions? please comment if need explain in more detail,

use button instead of input:

<button name='submit' type='submit' value='1'><fmt:message key="id001"/></button> <button name='submit' type='submit' value='2'><fmt:message key="id002"/></button> <button name='submit' type='submit' value='3'><fmt:message key="id003"/></button> 

and if want have click-able button, don't submit form, add type='button' it.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -