Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing values to jSP on button click

843836Jun 8 2004 — edited Jun 9 2004
Hello
I have multiple delete buttons on the JSP page. What i want is to get the value as to which delete button was clicked. I am not sure if i shld have multiple names for the buttons. For now all have the same name since its inside a while loop.
Also i want to confirm that the user really wants to delete the field. But i dont know how can i pass the value as well as the function at the same time through the onClick function.
I tried type="hidden" for the field value and onClick="function" (where function is a javascript function that confirms if the user does want to delete the field). BUt in this case with type = hidden i get all the values corresponding to the field.
Any pointers?

heres the sample HTML code if it helps.. this one is just to show how the screen looks like. The actual JSP has the while loop.. which is also pasted below
<HTML>
<HEAD><TITLE>File Format Management</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript" type="text/javascript">
<!--
var errMsg = "";
function confirmDelete(frm)
{
     var deleteSure = confirm("Are you sure you want to delete the fileType?");
     if (deleteSure)
            frm.submit();
     return deleteSure
}
//-->
</SCRIPT>
</head>
<body>
<BR>
<CENTER>
<TABLE border="1" cellpadding="0" cellspacing="0" marginwidth=0 marginheight=0>
  <TR class="titlebar">
    <TD align="center">File Format Management</TD>
  </TR>
  <TR bgcolor="#cccccc">
    <TD>
<B>File Types:</B>
<p>The following file types are defined for this project.</p>
<div align="center">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr><td>Filetype��</td><td># of fields��</td><th></th><th></th></tr>
<tr><td>Demographics</td><td align="center">5</td><td><input type="submit" value="Edit"></a></td><td align="right"><input type="submit" value="Delete"></a></td></tr>
<tr><td>Clinical</td><td align="center">17</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
<tr><td>MS</td><td align="center">9</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
<tr><td>HLA</td><td align="center">20</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
<tr><td>SNP</td><td align="center">18</td><td><input type="submit" value="Edit"></td><td align="right"><input type="submit" value="Delete"></td></tr>
<tr><td colspan="4"><input type="submit" value="Add new filetype..."></td></tr>
</table>
</div>
<p align="center"><input type="submit" value="Return"></p>
</td>
</tr>
</table>
</body>
</html>
//actual while loop in JSP
<table cellpadding="3" cellspacing="0" border="0" width="100%">
            <tr class="titleitem"><td>Filetype��</td><td># of fields��</td><th></th><th></th></tr>
            <% if ((!fileTypesFormats.equals(null)) && (fileTypesFormats.size() > 0))
                { 
                   
                    Iterator keyIter = fileTypesFormats.entrySet().iterator();
                    while (keyIter.hasNext())
                    {
                        Map.Entry CurrentEntry = (Map.Entry) keyIter.next();
                        String formatNos = CurrentEntry.getKey().toString();
                        String fileTypeName = CurrentEntry.getValue().toString();
                        count++;
             %>
                   <tr class="<%=htmlObj.getClassString(count)%>">
                     <td><input type="hidden" name="filetypeName" value="<%=fileTypeName%>"><%=fileTypeName%></td>
                     <td align="center"><%=formatNos%></td>
                     <td><input type="button" value="Edit" name="editBtn" onclick="location.href='edit_delete_filetype_format.jsp'"></a></td>
                     <td align="right"><input type="button" name="deleteBtn" value="Delete" onclick='confirmDelete(this.form)'></a></td>
                   </tr>
             <% } } %>
                    <tr class="<%=htmlObj.getClassString(count)%>"><td colspan="4"><input type="button" value="Add new filetype..." onclick="location.href='edit_delete_filetype_format.jsp'"></td></tr>
        </table>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 7 2004
Added on Jun 8 2004
5 comments
1,388 views