This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parameter passing to Java Script function

 
sanjivani g
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I'm trying to pass a parameter to the Java Script function in a servlet, but the parameter is being undefined in the function. Please let me know where I'm doing the mistake.
Here's my code :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ChPswdPJavaRanch extends HttpServlet {
String someVar="Some String";
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

HttpSession session = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();;
out.println("<html>");
out.println("<head>");
out.println("<SCRIPT LANGUAGE=\"JavaScript\">");
out.println("<!-- Begin");
out.println("function check(param) { ");
out.println("document.write(\"function parameter :\"+param)");
out.println("}");
out.println("// End -->");
out.println("</SCRIPT>");
out.println("</head>");
out.println("<body>");
out.println("<SCRIPT LANGUAGE=\"JavaScript\">");
out.println("javascript:check(this.someVar)");
//System.out.println(someVar);
out.println("</SCRIPT>");
out.println("</body>");
out.println("</html>");
}
}
Thank u
Sanjivani
 
Malu mathew
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
Change
out.println("javascript:check(this.someVar)");
to
out.println("javascript:check('"+this.someVar +"')");
U will get the parameter printed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic