Forums

Is it possible to display a "thanks, processing" on the form

zaphod71 16 Nov, 2008
Because I've shrewdly negotiated a 1 year contract with an overpriced and underpowered hosting company, sometimes there is a lengthy wait whilst processing a form (sometimes as long as 30 secs, sometimes instantaneous). Because of this, I would like to have a thanks this is processing text to appear under the submit button, in much the same way as the validation warnings, so nobody thinks the page has frozen. Then, they may stick around until the thanks page comes up!

Thanks for your help on this and previous questions.
Max_admin 16 Nov, 2008
Hi, may be try to add a div under your submit button code and onsubmit event for the button with a simple text like this :

<input type="submit" onclick="document.getElementById('somediv').innerHTML= 'Thanks, dont submit again';">
<div id="somediv"></div>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
zaphod71 16 Nov, 2008
Thanks for replying.

However I am still unclear.At present I just have

<input name="SubmitButton" type="submit" value="Submit" /> in my form and thats all I do. (apart from a redirect entered in the formURL box)
Could you explain in idiotspeak your suggestion?

Thanks for your patience!
GreyHead 16 Nov, 2008
Hi zaphod71,

Just add in the <div> tags and the JavaScript snippet that Max posted so that your input code looks like this
<div id='submit_message' >
<input name="SubmitButton" type="submit" value="Submit" onclick="document.getElementById('submit_message').innerHTML= 'Thanks, dont submit again';" />
</div>
This should replace the submit button with the message when it's clicked.

Bob
zaphod71 17 Nov, 2008
I really underplayed the idiotspeak part here - or at least the level of idiot!

I replaced my input with the 2nd bit of code that you suggested and it plays out exactly how I wanted on the form. However, it now no longer processes the form!

It now doesn't validate or process in any way, shape or form.

By the way, I would only want the button replaced or printed under if the validation has been passed, I'm probably wrong, but wouldn't this code, even if I interpreted it correctly, just print it as soon as the button is clicked regardless of validation success?

Just so I'm clear, I did absolutely nothing but replaced the code in my form. Is there another step that is so obvious even a well trained monkey would know about it?

<tr> <td colspan="2"><div align="center">
<div id='submit_message' >
<input name="SubmitButton" type="submit" value="Submit" onclick="document.getElementById('submit_message').innerHTML= 'Thanks, your form is being processed';" />
</div> </div></td>


Thanks for your continued patience.
GreyHead 17 Nov, 2008
Hi zaphod71,

Oops . . . sorry, I should have tested that first. This version works:
<input name="SubmitButton" type="submit" value="Submit" onclick="document.getElementById('submit_message').innerHTML= 'Thanks, dont submit again';" />
<div id='submit_message' > </div>
and this version will also disable the Submit button to stop them clicking a second time.
<input name="SubmitButton" type="submit" value="Submit" onclick="document.getElementById('submit_message').innerHTML= 'Thanks, dont submit again'; this.disabled=true;" />
<div id='submit_message' > </div>

Bob
zaphod71 17 Nov, 2008
Thanks very much for looking at it again!

The first one does as expected, the second one doesn't though (which is not an issue).

However, as I suspected in my previous post, it puts up the thanks please don't post again even if it fails the validation. This may put off people who need to post again if they made an error! Is there any way of putting this only if it passes the validation, but before it goes through the rest of the processing?
GreyHead 17 Nov, 2008
Hi zaphod71,

Hmmmm . . . I'm sure it's possible but I don't think it's simple . . . perhaps by looking at the classes in the page. I'll take another look but no promises.

Bob
Max_admin 17 Nov, 2008
try this:


    <input name="SubmitButton" type="submit" value="Submit" onclick="this..addEvent('onFormValidate', function(result, form) { if(result){document.getElementById('submit_message').innerHTML= 'Thanks, dont submit again'; }}" />
    <div id='submit_message' > </div>



I'm really not sure if this will work!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
zaphod71 18 Nov, 2008
Thanks, once again, for trying to help.

The above code didn't break anything. eg validation worked and the form db and email all worked.

However message didn't come up at all this time.
GreyHead 18 Nov, 2008
Hi zaphod71,

I think that maybe - this..addEvent - should be - this.addEvent - with only one dot. Please try that.

Bob
Max_admin 18 Nov, 2008
yes, please try the fix posted by Bob, its a typo of me!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
zaphod71 19 Nov, 2008
Thanks again,

Unfortunately, it made no difference.

It didn't break anything, it just ignored it.

As much as I'd like this solved, I think I've already took up to much of your time.

Thanks for trying.
Max_admin 20 Nov, 2008
what makes it harder is the validation, if you have a normal JS alerts validation then it would be easy, I need to test this code myself to know if its even possible, will try to do sometime but can't tell when exactly.

Best regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
zaphod71 20 Nov, 2008
I appreciate your help.
I don't want to undervalue your time, so I think it may be cost/time effective to swallow the contract and switch host.

Your response has been great. I wish Microsoft's support was even a quarter of good. Perhaps then I wouldn't have wasted a good six months on crm3!

Thanks again.
GreyHead 20 Nov, 2008
Hi zaphod71,

Here's a version that seems to work OK. In the JavaScript box:
function checkSubmit ()
{
    var form = $('ChronoContact_form_name');
    var valid = new Validation(form,{onSubmit:false});
    var result = valid.validate();
    if ( result ) {
        $('submit_message').innerHTML = 'Thanks, dont submit again'; 
        $('submit').disabled = true;
        form.submit(); 
    }
} 
Notice *form_name* in there - change to match your form!

In the form html:
<input name="SubmitButton" type="submit" id='submit' value="Submit" onclick="return checkSubmit();" />
<div id='submit_message' > </div>

This stops the automatic submit by the validation code and inserts the message display before submitting.

Bob
zaphod71 25 Nov, 2008
Thanks for the reply,

Seems to work flawlessly in terms of it appearing on the form (so I must have got that part right!)

However, for some reason it doesn't actually submit the data or continue on to the redirect page.
(I have checked I've put in the opening { and the two closing }'s)

Thanks for all your time.
GreyHead 25 Nov, 2008
Hi zaphod71,

Please remove any redirect url temporarily, turn DeBug on in the form General Tab and see if you get any out put when you submit. That will tell us if the form fails to submit or something goes wrong after that.

Bob
joomlanoob 04 Apr, 2009
Looks like a javascript solution was not trivial. Is it easier to show a "thank you" message on a validated submitted form using server side code? (The ServerSide Validation code block shows a red error box if there is a string, but there does not seem to be a mechanism for showing a "thank you" kind of message.)
GreyHead 04 Apr, 2009
Hi Joomlanoob,

Just answered your other post on this.

Bob
andyss 13 Nov, 2009
Hi guys, I have the latest version installed (3.1RC5.5) but when I try to use the above checkSubmit function, I get an error in the Firefox Error Console: "Validation is not defined" and the script doesn't work. Does this code need to be updated somehow?

Thanks.
andyss 19 Nov, 2009
Any update on my previous post guys?
GreyHead 11 Dec, 2009
Hi andyss,

Very late - but my guess is that the LiveValidation script files aren't being loaded? Do you have Validation enabled for the form?

Bob
mypethamster 12 Dec, 2009
addevent or addeventlistener work for different browsers.
IE seems to prefer 'onsubmit' (within form tag) to run the code correctly, that said, if you post to the same page you will need to add 'onclick' to the submit button, if not make sure you remove this onclick event.

anyway try this:
add

onsubmit="dothis(this);"

To: 'Form tag attachment:' under 'Core/View Form Settings'

and add this

function dothis(thisform)
{
with (thisform)
{
document.getElementById('SubmitButton').disabled=true;
}
document.getElementById('submit_message').innerHTML = 'Thanks, dont submit again';
}

to 'Form JavaScript:' under 'Form Code'

Edit: Make sure the submit button has id ref of id="SubmitButton" to reference.
GreyHead 12 Dec, 2009
Hi andyss,

Just looked again and the old script is for an earlier version of ChronoForms using a different validation suite. Try the code MyPetHampster suggested.

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