codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to insert Javascript within Javascript ?  sherbir at 10:51 on Wednesday, July 28, 2004
 

I have a simple problem.

I want to insert Javascript within Javascript ???
Seems weird !!!

Here's the scenario :
I have created a JSP in which I have a function that Submits the main form in the main window.
Here's the function :

function SubmitContent()
{
document.f1.method='post';
document.f1.action='http://localhost:8080/examples/sherbir/texteditor2/page2.jsp';
document.f1.submit();
}

and here's the form description :
<form name='f1'>

But before that, on clicking the submit button in the main window, I am opening a child window to perform a few operations as follows :
<input type="button" name="bttn_preview" value="Preview" onClick="javascript:SeePreview()">

Here's the SeePreview() function which opens the child window:
function SeePreview()
{
var mywin=window.open("","","menubar=no,toolbar=no,scrollbars=yes,width=800,height=450");
mywin.moveTo(0,50);
mywin.document.write('<input type=button value="Make more changes"
onClick=javascript:window.close()>');
mywin.document.write('<input type="submit" name="child_bttn_sub" value="Proceed" onClick=self.close(); self.opener.SubmitContent();>');

The child window in turn has a submit button as defined above.

On clicking this button, I want the child window to close and hence submit the parent form also.

It's not happening !!

I even tried changing the order of the two statements in the OnClick event of the submit button in the child window.
I also tried self.opener.document.forms[0].submit()

None works.

Where's the problem ??

How do I remedy the situation ?

Please Help.




© Copyright codetoad.com 2001-2004