0

Hi guys, i'm doing my FYP, and facing the following problem.
below is my code for the javaScript

<script language="JavaScript">
function deleteAccount(ckId){
  alert(ckId);
  var index = document.getElementById(ckId).value;
  document.getElementById('hiddenind').value = index;
  var conf = confirm("Are you sure you want to permanently remove this account?");
  if(conf == true)
	{
	document.form.action = "<%=contextPath%>/AccServlet?tranx=deleteAccount&empId=]?";
	document.form.submit();
        }
  else
  return;
 }
</script>

then inside the form

<input name="checkboxes" type="checkbox" value=""        onclick="deleteAccount(<%=accDto.getEmpId() %>)" />

I have test that the data can be pass to javascript using alert(ckId);. However the data can't be pass to this line in javascript:
document.form.action = "<%=contextPath%>/AccServlet?tranx=deleteAccount&empId=?

The '?' at the end of the line suppose to get the value of ckId and pass to servlet. However no matter how i try , thing i write to replace the '?' symbol is pass to servlet only, not its value.
========================================================
Below is the code inside the servlet:

if (request.getParameter("tranx").equalsIgnoreCase("deleteAccount")){
	url="/Acc/DeleteAcc.jsp";
	request.getParameter(empId);
	System.out.println("Test empId value: "+empId);
	accBean.deleteAcc(empId);
	dispatcher = getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);
	return;
	}

Edited by kio: n/a

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by gsting_88
0

Hi guys, i'm doing my FYP, and facing the following problem.
below is my code for the javaScript

<script language="JavaScript">
function deleteAccount(ckId){
  alert(ckId);
  var index = document.getElementById(ckId).value;
  document.getElementById('hiddenind').value = index;
  var conf = confirm("Are you sure you want to permanently remove this account?");
  if(conf == true)
	{
	document.form.action = "<%=contextPath%>/AccServlet?tranx=deleteAccount&empId=]?";
	document.form.submit();
        }
  else
  return;
 }
</script>

then inside the form

<input name="checkboxes" type="checkbox" value=""        onclick="deleteAccount(<%=accDto.getEmpId() %>)" />

I have test that the data can be pass to javascript using alert(ckId);. However the data can't be pass to this line in javascript:
document.form.action = "<%=contextPath%>/AccServlet?tranx=deleteAccount&empId=?

The '?' at the end of the line suppose to get the value of ckId and pass to servlet. However no matter how i try , thing i write to replace the '?' symbol is pass to servlet only, not its value.
========================================================
Below is the code inside the servlet:

if (request.getParameter("tranx").equalsIgnoreCase("deleteAccount")){
	url="/Acc/DeleteAcc.jsp";
	request.getParameter(empId);
	System.out.println("Test empId value: "+empId);
	accBean.deleteAcc(empId);
	dispatcher = getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);
	return;
	}

lolx i also wanna know!! no ppl here?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.