Forums

thank you in modal while form submits no refresh

thediligent 27 Oct, 2010
Hello I love chronoforms and have been using for a while, but I can't seem to get this doing what I really want it to. I am using a simple form that captures the email of a user and stores in a table. This is for newsletter purposes later. What I would ideally like to have happen is the user inputs their email, it live validates(hopefully) and when the user hits enter or clicks on the submit button (image right now) it would say thank you in a modal, stores the email data and then either have the user close the modal or it can close itself, not too worried about the closing right now.

I have example at http://www.raveandradha.com and the newsletter form is at the top right of the site. Currently if you add your email : test(at)test.com and hit enter, it does the normal chronoforms submit with redirect ( cause its a live site) but when you click the image to submit, it submits the form, opens the thank you on a modal window but then it takes the user to a blank page... again I am currently redirecting the page so that the user sees the thank you and it looks like a user expects, but with the redirecturl empty it still redirects to the blank task=send page.

Form code - HTML :
<?php
if ( !$mainframe->isSite() ) { return; }
JHTML::_('behavior.modal')
?>

<div class="form_item" style="padding-top:15px;">
  <div class="labelinput">
    <label class="cf_label" style="width: 150px;">JOIN NEWSLETTER</label>
    <input style="color:#888;" class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="email" type="text" value="enter email address" onfocus="this.value==this.defaultValue?this.value='':null" />


<a class="modal" onclick="javascript:submitform(); void(0);" href="/index.php?option=com_content&view=article&id=16&tmpl=component" rel="{handler: 'iframe', size: {x: 400, y: 400}}"><img src="images/stories/submit.png" /></a>


Form code - Javascript :
function submitform()
{
  document.ChronoContact_newsletter.submit();
}


Any direction or assistance would be appreciated thanks. I'm not a Javascript coder, but a pretty quick study.

Thanks and cheers.
GreyHead 28 Oct, 2010
Hi thediligent,

I think perhaps it would work if you set ChronoForms to redirect to the current page? Something like: FForm HTML
<?php
if ( !$mainframe->isSite() ) { return; }
$uri =& JFactory::getURI();
?>
<input type='hidden' name='uri' value='<?php echo $uri->toString(); ?>' />

And in the OnSubmit After box
<?php
$uri =& JRequest::getString('uri', '', 'post');
$mainframe->redirect($uri);
?>

Bob
thediligent 28 Oct, 2010
Thank so much for the response Greyhead, It still redirected to the blank page(correction: the enter key had the user redirect at the same page, and the button redirected to the thank you article no template), using that idea, I tried having the redirect url go to the homepage...but then I get no thank you message at all. It stored the data though.

I'm wondering is it even possible to store the form data in a table and popup a thank you message without needing any browser refresh, or redirect? I searched all over the web. Sometimes, I find myself trying to do something that is either really tricky or impossible. Anyway, thanks for the direction and any other ideas would of course be welcomed.
GreyHead 30 Oct, 2010
Hi thediligent,

I'm wondering is it even possible to store the form data in a table and popup a thank you message without needing any browser refresh, or redirect?,

I guess that you could do it with an Ajax form and a Javascript alert. I 've put a form and the thank you page in a modal window but never tried to do just the thank you page.

Bob
This topic is locked and no more replies can be posted.