closing popup

this is really a javascript question. off the cuff, what i would do
is submit the form. if the form data was successfully processed, use
some javascript to redirect the parent window to the location you want
then close the child window. if it failed, just redisplay the form in
the child window.

I'll leave the implementation up to you.

Can someone help me also to work out this scenario...
from a main window, i open a popup, then submit the popup, do some
server side call, after this i close the popup window and now i need to
update a DOM in my main window.
How can i acheive this or should i be looking for any other way.

Thanks in advance