Solved

onSubmit window.close?

Posted on 2004-08-03
8
2,095 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
ID: 11706176
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
ID: 11706224
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
ID: 11706242
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 33

Expert Comment

by:knightEknight
ID: 11706247
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
 
LVL 33

Expert Comment

by:knightEknight
ID: 11706256
can you clarify what you are asking for please?
0
 

Author Comment

by:mattybrigh
ID: 11706389
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
ID: 11706434
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
ID: 11706860
thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding Row and Cell on a table 14 25
Diminish Pop-up  in 3 seconds 7 44
Make Session back to empty 9 30
Html input text color the frame line 2 20
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

809 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