Servlet & JavaScript problem

Hi,

Firstly, this site is great .. Thanks to all that assists us all !!!

I am trying to have a javascript in my servlet coding. However, I am getting a javascript error, "Error on Page". This is shown on the status bar (on IE V6 SP2) when i try and click on the link. The code is below:

My Java is enabled(checked) on my browser.

os.println("User Successfully created");

os.println("<FORM ACTION=sp_user METHOD=post>");

os.println("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>");

os.println("<TR><TD>");

os.println("<form name=\"myform2\" method=\"POST\" action=\"sp_user\">");

os.println("<INPUT NAME=\"g_form\" TYPE=\"hidden\" VALUE=\"sp_user\">");

os.println("<INPUT NAME=\"g_first\" TYPE=\"hidden\" VALUE=\"YES\">");

os.println("<INPUT NAME=\"g_link\" TYPE=\"hidden\" VALUE=\"UPDATE\">");

os.println("<A HREF=\"javascript:document.myform2.submit()\">Update Profile</A>");

os.println("</form>");

I have also tried

os.println("<FORM ACTION=sp_user METHOD=post>");

os.println("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>");

os.println("<TR><TD>");

os.println("<form name=\"myform2\" method=\"POST\" action=\"sp_user\">");

os.println("<INPUT NAME=\"g_form\" TYPE=\"hidden\" VALUE=\"sp_user\">");

os.println("<INPUT NAME=\"g_first\" TYPE=\"hidden\" VALUE=\"YES\">");

os.println("<INPUT NAME=\"g_link\" TYPE=\"hidden\" VALUE=\"UPDATE\">");

os.println("<A href=\"javascript: submitform()\">Update Details</A>");

os.println("</form>");

os.println("<SCRIPT language=JavaScript>");

os.println("function submitform()");

os.println("{");

os.println("document.myform2.submit();");

os.println("}");

os.println("</SCRIPT>");

Can anyone assist me on this.

Thanks Kindly

Naren

[1981 byte] By [gokala] at [2007-11-27 11:17:01]
# 1

If you're getting that method then there is something wrong with your Javascript code. That is nothing to do with your servlet except that, trivially, you will have to change your servlet to write the correct Javascript code. Your first step should be to find out what's wrong with your Javascript. Your second step should be to correct that. This isn't a Javascript forum so if you need help with that, you should go and find a Javascript forum.

DrClapa at 2007-7-29 14:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

It is not

os.println("document.myform2.submit();");

but rather something like this:

os.println("document.getElementById('myform2').submit();");

Manuel Leiria

manuel.leiriaa at 2007-7-29 14:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...