469,343 Members | 5,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

window.document.formaname.submit() not working for some case.

Hi all,
the code where i am finding a problem is as follows:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. function fun1(){
  5. window.document.formName.action="/someServlet";
  6. window.document.formName.submit();
  7. }
  8. </script>
  9.  
  10. </head>
  11.  
  12.  
  13.  
  14. <body>
  15. <form  name="formName" action = "/ab.jsp" method ="post">
  16. <a href="#" onClick="fun1();" >Some Link</a>
  17.  
  18. </form></body>
  19. </html>
  20.  

The problem here is when i click on the hyperLink it goes to the onClick method and from there the action is set to be redirected to a servlet(even when action was set to a jsp it didnt work), but it doesnt call the submit() method after that,...


Why is this so???

Plz do clarify the doubt....
Nov 19 '07 #1
7 2430
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

I've never worked with servlets so this may be a useless question, but do servlets not require an extension, e.g. .jsp?

Try:
Expand|Select|Wrap|Line Numbers
  1. document.forms["formName"].action="/someServlet";
  2. document.forms["formName"].submit();
Your form doesn't have any elements, so what's going to be posted?
Nov 19 '07 #2
Hi...
Well the action is going to some controller which in my case is a servlet.
I put alert before the submit() method. I am even gettin that alert but after that the form is not getting submitted....
Why is it so???
Nov 19 '07 #3
acoder
16,027 Expert Mod 8TB
Try adding some form elements. It's an empty form.
Nov 19 '07 #4
I have some table and div in the form i am workin in,,,,
So wat after that
Nov 19 '07 #5
acoder
16,027 Expert Mod 8TB
I have some table and div in the form i am workin in,,,,
So wat after that
Post the code. Do you get any errors?
Nov 19 '07 #6
Well the flow is as follows...
There is one jsp(java code in HTML file) by name Options.jsp and it has a top file called TopFrame.jsp . there is a hyperLink in Options.jspt file say like this:
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0);" onClick="logoff()">Logout</a>

this logff() method has code like this
Expand|Select|Wrap|Line Numbers
  1. top.close();

the Topframe.jsp has in its body onLoad method calls one more logOff method in that TopFrame.jsp file.
In this logoff method i am calling
Expand|Select|Wrap|Line Numbers
  1. document.formname.action="/someservlet"
  2. alert("Came before submit");
  3. document.fromname.submit();
  4.  
i reach till the alert message is thrown but after that submit is not called.... This is wat my concern was./...
Nov 19 '07 #7
acoder
16,027 Expert Mod 8TB
Check your code that it doesn't contain form elements with the name "action".

Do you not see any errors?
Nov 19 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Display Name | last post: by
4 posts views Thread by GTi | last post: by
1 post views Thread by Terence Parker | last post: by
14 posts views Thread by D. Alvarado | last post: by
2 posts views Thread by jackson2005 | last post: by
5 posts views Thread by midnight_use_only | last post: by
2 posts views Thread by Devika | last post: by
11 posts views Thread by V S Rawat | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.