-2

I have a javascript function in jsp page like this:

function shutDownall(){
  alert(document.forms[0].Name.value);
  var app_nm=document.forms[0].Name.value;
  alert(app_nm);
  document.forms[0].action="<%=request.getContextPath()%>/controller?eventName=shutDownall&appname=" +app_nm;
  document.forms[0].submit();
  return true;

}

and a button like this which calls javascript function:

<button type="button" onclick="javascript:shutDownall();">shutdown servers</button>

where the javascript function is calling a method declared in action class. And button calls the javascript function calling java method. But when i click the shutdown server button nothing happens, not able to debug it. please help.

VPK
  • 3,010
  • 1
  • 28
  • 35
user1795999
  • 301
  • 2
  • 5
  • 15

1 Answers1

1

if you are using the script in separate page be sure that the script file is included in the head of the page , but if the script in the same page you have to put this script before that button.

Anas Omar
  • 504
  • 3
  • 8
  • i am using script in same page which script we should put before button? – user1795999 Jan 19 '15 at 07:09
  • this script put it in the head function shutDownall(){ alert(document.forms[0].Name.value); var app_nm=document.forms[0].Name.value; alert(app_nm); document.forms[0].action="<%=request.getContextPath()%>/controller?eventName=shutDownall&appname=" +app_nm; document.forms[0].submit(); return true; } and the button but it like this – Anas Omar Jan 19 '15 at 07:48