I am writing a javascript inside java servlet to get
the function "alert", that is , when one trying to
modify two records at one time, error message like
"you can only modify one record at one time" comes out
in a new small window. then the servlet program will
be redirected to another servlet program. firt the
javascript function works well. but when i add one
piece of code
res.sendRedirect("/labexam/servlet/StudentEdit");
the javascript function doesn't work even it is
called.
the following is my code

 out.println("<html>");

          out.println("<head>");
          out.println("<title>Student Edit Menu</title>");


          out.println("</head>");

          out.println("<body  bgcolor=#ccffff>");
          out.println("<h1 align = center><font size=5
color=green >"+courseid.toUpperCase()+": "+
course+"</h1>");

          out.println("<p>");
          out.println("<p>");

          if (errorFlag == true) {// if there is error in
selection, set target=_self
              out.println("<form
action=\"StudentEditModule1\" method=Get
Target=_self>");
              System.out.println("errorflag is true");
          }
          else{
                System.out.println("errorflag is false");
              out.println("<form
action=\"StudentEditModule1\" method=Get
Target=_parent>");
          }
          out.println("<table align=center >");

          out.println("<tr><td>");
          out.println("<select name=\"action\">");
          out.println("<option value=\"Add\">Add");
          out.println("<option value=\"Modify\">Modify");
          out.println("<option value=\"Delete\">Delete");
          out.println("<option value=\"Upload\">Upload
File");
          out.println("</select>");
          out.println("</td>");
          out.println("<td>");
          out.println("<input type=\"submit\" value=\"Go\"
>");
          out.println("</td>");
          out.println("</tr>");

          out.println("</table>");

          out.println("</form>");
          if (errorFlag==true) { // if there is error in
selection, pop up error message
              System.out.println("the error message function
is called");
              out.println("<script
language=\"JavaScript\">");
              if(numOfSelection==0)
                  out.println("alert(\" At least one record needs to
be selected\")");
              else  // more than one record for modify
function
                  out.println("alert(\" Only one record can be
modified at one time\")");
              out.println("</script>"); // end of javaScript


               }

           out.println("</body>");
          out.println("</html>");
          if (errorFlag ==true)

res.sendRedirect("/labexam/servlet/StudentEdit");
          // close connection



______________________________________________________________________
Web-hosting solutions for home and business! http://website.yahoo.ca

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to