Close Thickbox after form submission

LZ1
LZ1 used Ask the Experts™
on
Hey Experts!!

I have a form that opens in a Thickbox.  The site is hosted through Godaddy and I'm using their gdform.php.  
What I need to know how to do is simply close the thickbox after the form has been submitted.  I've looked all over google and can't find something that will work in my case.  I don't need to pass variables, I just need to close the thickbox after the form has been submitted.
The form is below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../css/base.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<form action="gdform.php" method="post">
  <input type="hidden" name="redirect" value="thanks.html" />
    <div> <label>Name: </label>
    <input name="1name" type="text" size="30" /></div>
    <div><label>E-Mail: </label>
    <input name="2email" type="text" size="30" /></div>
    <div><label>Phone: </label>
  <input name="3phone" type="text" size="30"  /></div>
    <div>
      <label>What should we know prior to contacting you:</label>
      <textarea name="5comment" cols="30" rows="5"></textarea></div>
  <label>
<button>Submit</button></a> 
  </label>
</form>
 
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Try this:

<form action="gdform.php" method="post" onsubmit="javascript:tb_remove();">
  .....
</form>

Open in new window

LZ1
Top Expert 2011

Author

Commented:
Unfortunately that didn't work.   It kept throwing a "Page not found" error.  Which I KNOW the page is there.  I uploaded it quite a few different times.  


Commented:
Hmm.  Does your form submit with AJAX?  Or are you loading the form in an iframe in the Thickbox?  Because if it's a normal submission, wouldn't it reload the page, and thus close the thickbox?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

LZ1
Top Expert 2011

Author

Commented:
anoyes:
There's no AJAX, it's the default form that Godaddy uses.  It's PHP based.  After it submits it redirects to your home page unless you have a hidden redirect in the form itself.
If I can have it redirect and then use that page to close the thickbox that would be fine too.  Either way really.  
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
I suggest you put this in the "thanks.html" page.
<script type="text/javascript">/* <![CDATA[ */
window.onload = function(){ /* quick and dirty onload event handler */
  if(parent) parent.tb_remove();
}
/* ]]> */</script>

Open in new window

LZ1
Top Expert 2011

Author

Commented:
Still nothing.  It keeps saying the page can't be found.  The form is being processed so that's good.  But it's just not closing the thickbox.  
Here's the actual link.  Click the contact us in green
http://430designs.com/real-estate/test1.html  
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
I'm getting a "Bad Request" message when I fill out and submit the form.  Maybe gdform.php is made to not allow form submissions from other domains (http://a12.alphagodaddy.com/).
LZ1
Top Expert 2011

Author

Commented:
Not sure if you can tell Kravimir, but here is the form.  I'm not that good with PHP yet.

 <?php
	$request_method = $_SERVER["REQUEST_METHOD"];
	if($request_method == "GET")
	{
		$query_vars = $_GET;
	} 
	elseif ($request_method == "POST")
	{
		$query_vars = $_POST;
	}
 
	reset($query_vars);
	$t = date("U");
	$file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t;
	$fp = fopen($file,"w");
 
	while (list ($key, $val) = each ($query_vars)) 
	{
		fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n"); 
		fputs($fp,"$val\r\n");
		fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\n");
		if ($key == "redirect") 
		{ 
			$landing_page = $val;
		}
	}
 
	fclose($fp);
	
	if ($landing_page != "")
	{
		header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
	} 
	else 
	{
		header("Location: http://".$_SERVER["HTTP_HOST"]."/");
	}
 
?>

Open in new window

David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
It creates a file and writes the contents of the form to it; then it redirects.

The usage instructions (http://help.godaddy.com/article/512#gdform) seem to indicate that you should use:

<form action="/gdform.php" method="post">

instead of

<form action="gdform.php" method="post">
LZ1
Top Expert 2011

Author

Commented:
Changed it to what you suggested.  Now it's the "Bad Request" error.  
LZ1
Top Expert 2011

Author

Commented:
The form did process though
Consultant & Challenge Subduer
Top Expert 2009
Commented:
I was wrong about the cause of the error message. The script expects a relative URL instead of an absolute one. (I should have looked at the redirects more carefully before making my last reply.) So change

<input type="hidden" name="redirect" value="http://430designs.com/real-estate/thanks.html" />

to

<input type="hidden" name="redirect" value="real-estate/thanks.html" />
LZ1
Top Expert 2011

Author

Commented:
PERFECT!!  I need to use this on more than one project so this is HUGE!!  Thanks Kravimir.
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
> PERFECT!! I need to use this on more than one project so this is HUGE!! Thanks Kravimir.

You're welcome.

If you want to use a form processor a lot, then I recommend you find a better one.  You might find a better one here: http://www.hotscripts.com/category/php/scripts-programs/form-processors/

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial