Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-24 11:07:23

mrjysta
Member
Registered: 2008-09-22
Posts: 89

Integrate thickbox with Zem Contact Form using Ajax

Hi guys, I want to launch a simple contact form as a popup using thickbox.

On the thickbox site they say you can request using Ajax http request, GREAT!!!
Im not sure if this will work as my contact form is a static page and so doesn’‘t have a full url. (www.mydomain.com/contact/)

Has anyone done this on their own textpattern sites ???

thanks/

Offline

#2 2009-04-24 14:06:52

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

This is a bit complicated – but here it is:

Inside TXP create a page called contact_form and one called ajax
Place the code below in both of them.

<html>
<head>
<script type="text/javascript">
// <![CDATA[
var zcr = {
ajax: {
options : function(form,url) {
return {
target: '#contactform',
url: url,
success: function(msg) { 
var newForm = $("#" + form.attr("id"));
var options = zcr.ajax.options(newForm,url);
newForm.ajaxForm(options);
	},
beforeSubmit: function() {
form.find('input#zemSubmit').toggle()
form.find('input#zemSubmit').parent().append('<img class="loadingImg" src="<txp:site_url />images/loadingAnimation.gif" alt="waiting" />');
	} // end beforeSubmit
	};
	} //end options
	} //end ajax
};
$(document).ready(function() {
	$('form.zemContactForm').each(function() {
		var options = zcr.ajax.options($(this), '/ajax');
		$(this).ajaxForm(options);
	}); //end each
}); //end document.ready
// ]]>
</script>
</head>
<body>
<div id="contactwrap">
<txp:zem_contact form="contact-form" to="enter-an-email-address-here" label="" copysender="0" subject='Message from the <txp:site_name /> website' show_error="1" thanks_form="contact-thanks" />
</div>
</body>
</html>

So you now have 2 new pages in TXP – one called contact_form and another called ajax

To call the contact form in a thickbox
<a href=”<txp:site_url />contact-form?height=450&width=600” class=“thickbox” title=”“>Contact Us</a>

Now you will have a thickbox contact form that will return any errors or success messages inside the thickbox window.

Update
  • You also need to create 2 sections for the pages to use. (ie: contact-form and ajax)
  • make sure you wrap your form elements with @<div id=“contact-form”></div>


Tom

P.S. You will need a loading animation in your images folder – in the code above it’s called loadingAnimation.gif.
You can make your own here

Last edited by renobird (2009-04-24 16:06:23)

Offline

#3 2009-04-24 14:55:37

mrjysta
Member
Registered: 2008-09-22
Posts: 89

Re: Integrate thickbox with Zem Contact Form using Ajax

Nice one Tom, error handling aswell !!! Thank you !!!

Offline

#4 2009-04-24 14:57:38

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Let me know if you have any probs getting it to work.
Some of that was off the top of my head – and some was from a script that Matthew Smith and Hakjoon posted a few years back.

I’ll assist if needed.

Good Luck.


Tom

Offline

#5 2009-04-24 15:18:40

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Schnazz, Reno, Schnazzz!

Offline

#6 2009-04-24 15:37:29

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Thanks. I’ve got a few other tricks around here as well – I need to get my arse over to TXP tips and get all this stuff up there.

:)


T

Last edited by renobird (2009-04-24 15:37:42)

Offline

#7 2009-04-24 15:55:37

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Do you need to create sections that use these new pages?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#8 2009-04-24 15:58:22

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Yep. Forgot to mention that.

:)


T

Offline

#9 2009-04-24 16:01:20

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Also – make sure in the form “contact-form” you wrap the entire thing in <div id=“contactform”></div>
You can build the rest of the form any way you like.


Tom

Offline

#10 2009-04-24 16:38:20

mrjysta
Member
Registered: 2008-09-22
Posts: 89

Re: Integrate thickbox with Zem Contact Form using Ajax

Yeah this would make a great TXP Tips tut !!!

Offline

#11 2014-03-07 14:37:16

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

Trying to use the method. After submitting the form the page reloads like usually.

Offline

#12 2015-07-19 19:45:31

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: Integrate thickbox with Zem Contact Form using Ajax

I also tried to follow these steps but no luck. I’d like see it in a step by step tutorial because I get lost in the middle of the explanation.
I know it is an old post, but anybody was able to achieve it?
Best regards
Fernando

Offline

Board footer

Powered by FluxBB