Submit form without going to another page

Status
Not open for further replies.

sebas

New Member
Hi

Is there a way to make the submit button submit the form and stay on the same page (without going to a jump page or thank you page)? specially if I'm using a formbot in a content page and I don't want to leave the content page after submitting.

Thanks.
 
That would require AJAX form submission, which we currently don't have. It's something we've considered, and may show up in 2.0 at some point, but for 1.0x, I'm afraid not.

You could theoretically do it yourself using the userAjax method, but there would be several gotchas to overcome. It might not be impossible though. I'll give it some thought.

-- hugh
 
Well, I don't really have any experience in Ajax, so I don't think thats going to be the way for me. Can I just jump to the same form with the data that I've just submitted in it? I know that I can specify the row number in the URL, but how do I tell Fabrik that the row is the record I've just submitted?

Thanks for the reply Hugh!
 
As of todays SVN you can use this as your jump page:

Code:
{HTTP_REFERER}

which will take the form back to its original page after submission.

This also means that you can access all the php $_SERVER variables throughout fabrik with the same syntax
 
Sebastian Chavez said:
I know that I can specify the row number in the URL, but how do I tell Fabrik that the row is the record I've just submitted?

Your inserted (or edited) rowid should be automagically appended to the jump page URL.

I haven't had time to test if this will work in conjunction with Rob's {HTTP_REFERER} changes from the previous post. My worry is that if the URL has an empty "&rowid=" argument, this may short circuit the automagic adding of the inserted rowid. So if it doesn't work using {HTTP_REFERER}, just paste the actual URL of the form in there, without a rowid.

-- hugh
 
Thank you both!

I'm going to update to the latest SVN and try both ways to see what happens.

Thanks again guys, great work!
 
I've been playing around with mootools and ajax stuff for really the first time over the last week or so, and I more or less accidentally got this working.

Just two steps:

1. Edit the <form....> code and add an 'id="....":
Code:
<form class="fabrikForm" id="fabrikForm" action="<?php echo $this->form->action;?>" <?php echo $this->form->js;?> method="post" name="<?php echo $this->form->name;?>" enctype="<?php echo $this->form->encType;?>">

2. At the bottom of the template, put this javascript code:
Code:
<script type="text/javascript">
$('fabrikForm').addEvent('submit', function(e) {
new Event(e).stop();
this.send();
});
</script>

A new row will be inserted in to the database, but nothing, literally nothing, will happen when you click the submit button. It was only after I happened to be checking over my tables in phpMyAdmin that I noticed it was actually submitting the forms.

It works for me, but it's suspiciously simple, so maybe it's just my setup?
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top