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!

Delete data dynamically with JSP and servlet (Very Urgent)

843838Jun 6 2007 — edited Jun 18 2007
Hi,
I am new with servlets and JSP. On my jsp page I am populating customer names in a drop box from database and I have 3 buttons ADD, DELETE and EDIT.
Now when I press DELETE buttong I am calling delete function which is writen in Javascript on my jsp file only,now I want to pass these selcted values ehich I have stored in an array to be pass to servlet,so I can write Delete query for it and delete.
Could anyone help with sample code>

Here what I am trying to say:

<HTML>
<HEAD>
<script language="JavaScript" type="text/javascript">
<!--

function remove()
{
var u = confirm("Are you sure you want to Delete Selected names?")

if (u==true)
{

var selectedArray = new Array();
var selObj = document.getElementById('CUSTOMER_NAME');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options.selected) {
selectedArray[count] = selObj.options[i].value;
count++;
}
}
alert("names to be deleted are:"+selectedArray);
// selectedArray has the selected items stored
alert("Items Deleted!")
}
else
{
alert("No data were deleted!!You pressed Cancel!")
}


}

//-->
</script>
</HEAD>
<BODY>
//calling servlet on action tag of form
<FORM METHOD= 'POST' ACTION='Remove_Customer'>


<form ><INPUT TYPE='submit' NAME='DELETE' VALUE='DELETE' onclick="remove()"></TD></form>
<form><INPUT TYPE='submit' NAME='MODIFY' VALUE='MODIFY' onclick="modification()" ></TD></form>
</BODY>
</HTML>

PLEASE HELPME,it's very urgent.
Since the selected Array is in javascrip language , I don't know how can I pass that to servlet.
request.getParameter is not working,since it's an array
Many thanks in Advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2007
Added on Jun 6 2007
30 comments
2,848 views