Close Shadowbox and submit form

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Close Shadowbox and submit form

imperiumza
I have a page with a iframe that this call a new form opening a shadowbox. I using this code provieded by Wizzud :

<script type="text/javascript"> var sbx = window.parent.Shadowbox; function openTopSBX(el){ if(sbx){ sbx.open( { content : el.href , player : 'iframe' , title : el.title||'' , height : 650 , width : 650 , modal : true //could include width/height/options if desired } ); return false; } else{ //no Shadowbox in parent window! return true; } } </script> 
this code works fine, this open my form and I can submit the form, but the URL redirected appear in the same Shadowbox window and not close the window.
When I use in the iframed page this code:

window.parent.Shadowbox.close();

this close the window but don't submit the form.

Can you help me how to close the window submiting the form??

Thanks a lot

P.D: Sorry by my bad english
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

Wizzud
The script you have posted enables the following...

  Page A
    iframe[1], containing Page B (has the posted script)

Then, Page B tells Page A to open Page C (containing the form) in a Shadowbox iframe...

  Page A
    iframe[1], containing Page B (has the posted script)
    iframe[2], containing Page C (the form, with a standard submit to itself)

When the form on Page C is submitted using a standard submit, the resultant page will appear in the current frame, ie. iframe[2]. My (limited) understanding is that the resultant page may be Page C again - or similar - (if the form submittal was invalid), or Page D (if the form submittal was valid). If Page D is the resultant page (ie. the form was valid) then you want it open in iframe[1] instead of iframe[2]?

To do that, you could return a different page, Page E, from a valid submittal. Page E runs a script located on Page A. That script on Page A closes its Shadowbox (iframe[2]), and then changes the src of iframe[1] to Page D. (The url to Page D can be returned as part of Page E, and then passed to Page A when calling the script).

This is all complicated by the fact that you have Shadowbox running from the top frame, but with content initially controlled by and subsequently affecting an entirely different iframe. You need to think very carefully about your cross-frame controls, and whether you actually need the different iframes.

This is all based on my limited understanding of what you are trying to achieve, which may be incorrect!
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

Josue
In reply to this post by imperiumza
after much searching i bumped into the solution:


 
<form name="loginform" id="loginform" action="<?=$blogurl ?>/wp-login.php" method="post" onsubmit="window.parent.Shadowbox.close();">

hope this helps

the onsubmit part is the trick :p
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

shakti_prem
This worked for me

    < input type=button value="Close Window" onClick="parent.location.reload();parent.Shadowbox.close();" >
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

venember
In reply to this post by Wizzud
I have repeaed my email because it also connects to these messages:
I have a mainly similar problem, I would like to ask your help:

My program is a login program called from the home page by shadowbox (I have no enough space in the home main page):

Login program structure:

1. common click to somewhere         -----> return to main page
2. login conditions  (submit button1) <====> if error, could show the error message and stay in the      shadowbox
             |
             ˇ
  if correct, conditional jump to page1, page2, page3, page4, page5 (depending on other radio buttons)
3. Two other buttons (submit button 2,3) to jump directly (password reminder, profile manager) to page6, page7.

The problem is that the I cannot make conditional close in the shadowbox in point 2. I can go back to the main page (onsubmit) or jump, but I can not perform this function together in same code.

I can insert the URL if it is necessary.
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

dragonfire
I tried the first solution to this thread by placing onsubmit="window.parent.Shadowbox.close(); in the action of the form. It closes the window on submit, but the validation needed for the form does'nt take place then. Is there a sound way around this?
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

chatmasta
For anyone who sees this, here is the solution...


In your form signature, include target="_parent":

<form method="post" action="validate.php" target="_parent">

Then do the onSubmit in the submit button:

<input type="submit" onsubmit="window.parent.Shadowbox.close();" />
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

chatmasta
Sorry, nevermind, that wasn't working.

You don't even need the onSubmit. You just need to set the target to _parent and do a redirect to the parent on the validation page.
Reply | Threaded
Open this post in threaded view
|

Re: Close Shadowbox and submit form

Kiran
In reply to this post by chatmasta
Just give target=_parent" in form