• Post Reply Bookmark Topic Watch Topic
  • New Topic

JS problem for window.close and form submit  RSS feed

 
shankha bhattacharya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sudip da ,

I am facing a problem for Form submitting using java script.



JS code is :



function onClickAddTransRecv()



{



// actionType is the hidden variable in the JSP page.



document.TransRecvInfoForm.actionType.value = "addTransRecvSubmit";



document.TransRecvInfoForm.submit();



//window.alert("TransRecvInfoForm form submitted");

OR

// alert("TransRecvInfoForm form submitted");



window.close();

OR

self.close();

}



In the action class I try to fetch the value of actionType using



String sAction = (String) request.getParameter("actionType");







Using this code when I submit the form in the Action class I get the value of "actionType" is null instead of "addTransRecvSubmit".



But if I use "window.alert" OR normal "alert" between Form submission and window closing I get the value of "actionType" is "addTransRecvSubmit" in the Action class.



Please help
 
Vijayender Bandaru
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem might be that the window is being closed before the data is submitted.The go around for this is:

Remove following code from your functon




and call the once you call your new function as follows:



That should solve your problem.

-Vijay
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch, Vijay
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!