I need to be able to submit back to the same form so that I can run PHP and JavaScript based on the values submitted. I want users to be able to submit the form as many times as needed because based on values that they enter, results will vary.
When I submit the form, the results don't display a new form.
Hi tadosborn,
There are a couple of ways to do this depending on how you want the back-end processing to be handled.
Your Javascript can be run without actually submitting the form.
The easy way to do PHP proccessing if it is fairly minor is by using the server-side validation box. If you 'return' a message there the form will automatically be re-shown and will keep the values - you can modify them in your PHP if you need to.
Second choice would be to use AJAX and call the PHP from the form using a little JavaScript (ChronoForms can support this now).
Third choice is to fully submit the form, do the processing and use the showform()* function to reshow it with selected values. This is a more complex to code but gives you fuller control over what happens when if you need it.
Bob
* The function name may have changed in RC5.0 but the capability is still there.
Hi,
in the onsubmit after email:
$MyForm =& CFChronoForm::getInstance('form_name');
$MyForm->showForm($MyForm->formrow->name, $_POST);
this will reshow the form after its submitted ready for a new submission! the whole $_POST array is passed to the form as well!
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
I can't get this code to work. Is there any documentation on the built in functions? I can't find anything on the site. I included the php tags and still no go.
Any help would be appreciated!
Hi tadosborn,
Do you want to re-show the blank form or show it with some results?
The code Max posted looks good to me. Please show us what you have used and where?
Bob
I followed the directions and pasted the code in the On Submit code - after sending email:
<?php
$MyForm =& CFChronoForm::getInstance('form_name');
$MyForm->showForm($MyForm->formrow->name, $_POST);
?>
I would like to show the data that was submitted. Also, select boxes do not retain their submitted values. Do I need to do anything additional to retain those values?
Hi tadosborn,
Silly question but did you change 'form_name' to the name of your form?
Bob
No, not a silly question. I missed that! Thank you. That was the problem.
I still would like to have my form retain the select box options that are selected when the form is submitted.
Again, thank you for your help!
I spoke too soon. I receive error 500 after submitting the form.
My form name: LensWizard
<?php
$MyForm =& CFChronoForm::getInstance('LensWizard');
$MyForm->showForm($MyForm->formrow->name, $_POST);
?>
I upgraded to lateest build which allows the code to execute that I was having problems with, however none of my form data is displayed.
Again, I appreciate your help!
Hi tadosborn,
For the check boxes try setting the "ChronoForms handle my posted arrays:" to Yes
When you say none of your form data is displayed - is the data still in the database - or did you uninstall to upgrade?
Bob
I haven't been storing the data in the database. Is that a requirement in order to display the information in the form?
I saved the forms,uninstalled the old version (last stable release 3.0) and installed the latest RC version, then restored my forms.
My form doesn't use checkboxes. I needed the select boxes to retain their values.
I neglected to clear my cache. My form appears to be working now.
Thank you!
Hi tadosborn,
No you don't need to store data in the database to re-show the current form data (you do to get data from other submissions of course).
Select boxes aren't usually a problem (check boxes are) but the old script in the cache would explain that.
Glad it working for you.
Bob