Form action to #?

Woncler 09 Feb, 2013
Hello,

I've built a nice form with Chronoforms, but there's one last thing I'd like to do. It works perfectly, but when I click submit, it redirects me to a page where it shows all the "On Submit" actions.

So, is it possible to set the whole form's action to # and load the "On Submit" actions in the main form page, so that on submit it shows the thank you message and possible PHP validation error messages below the form and not on a new page?

All suggestions and help will be much appreciated🙂
GreyHead 09 Feb, 2013
Hi Woncler,

I'm confused by what you describe here. Usually any Validation messages will be shown by reloading the form so that errors can be corrected. A Thank You page is shown on a separate page because by then the form is complete.

If you are seeing both together then the form isn't correctly set up.

Bob
Woncler 09 Feb, 2013
Oh, I try to clear myself up:

I have the following custom code action in On Submit:


...
   if($nimi == "")
   {
    echo "Kirjoita" . " nimimerkkisi.<br>";
   }
   if(!is_numeric($pisteet))
   {
    echo "Kirjoita oikea" . " numero.<br>";
   }
   if($syy == "")
   {
    echo "Kirjoita" . " syy.";
   }
   if(($nimi != "") and (is_numeric($pisteet)) and ($syy != ""))
   {

//declare in the order variable
$result = mysql_query($order);  //order executes
if($result){
  echo("<br>Pisteet tallennettu!");
  }
} else{
  echo("<br>Pisteitä ei voitu tallentaa😟");
}


So I didn't use the built in server side validation and the code saves the data into a separate DB. The javascript validation of course is working on the same page as the form.
GreyHead 09 Feb, 2013
Hi Woncler,

Well yes, anything that you 'echo' in the On Submit event will show up in the same page as the Thank You message.

But then that's why ChronoForms has the Custom Serverside validation action to handle this correctly. Please see this FAQ

Bob
Woncler 09 Feb, 2013
Ok, thanks. But if I would add the same custom code to On Load events, would I be able to set the form's action to read that specific code on submit, and not the On Submit events..? I tried to change the submit url to #, but it redirects me to mypage.com/index.php#
GreyHead 09 Feb, 2013
Hi Woncler,

As you've discovered, HTML forms don't work like that.

You can't expect to make things up and have them work - sometimes the world is like that most often it's not. If you want your form to submit to ChronoForms, then you need to use the ChronoForms URL. The # mark is a Fragment Identifier used to identify a specific location on the current page, or the top of the page if the fragment is empty.

Bob
Woncler 09 Feb, 2013
Yay, I got it working! I just moved the code to On Load events and left On Submit blank, and added the form's url + # to the form's URL field. Now it shows the messages above the form. Thanks for the support🙂
GreyHead 09 Feb, 2013
Hi Woncler,

Well done!

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