Solved

onSubmit window.close?

Posted on 2004-08-03
8
2,089 Views
Last Modified: 2008-03-03
I have a page that opens up a new window.  Here's that code:

<a href="javascript:;" onClick="window.open('addedit.asp?id=<%=RS("id")%>','inventory','toolbars=no,status=no,scrollbars=no,height=275,width=550');"><%=RS("item_name")%></a>

This works fine, but when the user edits what's in that window, it doesn't close.  Can someone tell me what might be wrong with this code?

<form action="submit.asp" method="post" OnSubmit="window.parent.close();window.close();return confirm_delete()">

Any help is greatly appreciated...
0
Comment
Question by:mattybrigh
  • 5
  • 3
8 Comments
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
I'm not exactly sure what you are asking for, but if you want the "inventory" window to close when the form submits, do this:

<form action="submit.asp" method="post" OnSubmit="window.open('','inventory').close();return confirm_delete();">
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
Comment Utility
better:


<a href="#" onClick="window.open('addedit.asp?id=<%=RS("id")%>', 'inventory', 'toolbars=no,status=no,scrollbars=no,height=275,width=550');return false;"><%=RS("item_name")%></a>



<form action="submit.asp" method="post" OnSubmit="if (confirm_delete()){window.open('','inventory').close();return true}else return false;">
0
 

Author Comment

by:mattybrigh
Comment Utility
Hmmm...didn't seem to work.  The form works, but once you submit the changes, it goes back to the default.asp page in the popup window.
0
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
or even better, add the close statement to the confirm_delete() function just before "return true" in the function.
Then all you need to do is:  onsubmit="return confirm_delete();"
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
can you clarify what you are asking for please?
0
 

Author Comment

by:mattybrigh
Comment Utility
I have a page with items on it, the user will click on an item to edit it.  When it's clicked, it opens up a new window (inventory).  They do all their stuff and then when they click the "Edit Inventory Item", the window is supposed to close.  This doesn't happen.  It just displays the default.asp page (the one with all the items on it) in the popup window.
0
 

Author Comment

by:mattybrigh
Comment Utility
Ok, I figured it out.  There were two forms on the page, the first one for the majority of the fields and a second one that was only used if you delete and item.  I was placeing all of that information there.

Thanks for the help and enjoy the points!
0
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now