How to avoid displaying newsletter form if it is submitted or close once? - forms

I am using mautic form.
I have added form code in my header script and this script always run on every page so how can I avoid to display that form if user close form or he has submitted it before.

Paste the script to the content of your page where you want the form to display. That way it will appear only on the page you want it to show up and on the place you want it to show up.
If you want to display another content after the form submission, configure the after submit redirect URL in the form's configuration.

Related

Unable to hide content snippet on form submit in portals. Displays along with the success message after form submission

I am working on partner portal in dynamics 365 portals.
I included a content snippet(qrcode scanner) in the 'upload result' web page. This web page also has an entity form placed in it after the content snippet.
When I load the web page, the content snippet and the form display on the web page(as expected).
After filling the required details and submitting the form, the content snippet doesn't hide on form submission.
It still is displayed on the page along with the success message.
I added the following code in the Additional settings of the Entity form of the web page,
$(document).ready(function(){
$("#InsertButton").click(function(){ // onclick submit button
$('#snippet-scanner').parent().hide(); // hide the content snippet
});
});
it hides as soon as we click the submit button but then re-appears along with the success message.
Can you please suggest me a way to hide or remove the content snippet from the web page when the success message is displayed, after the form is submitted.
Your problem here is that the page reload on form submit. I see 3 possible solutions.
Quickfix - check if form exists on page load and hide content snippet dependently.
$(document).ready(function() {
if (!$(".entity-form").length) {
$("#snippet-scanner").hide();
}
})
My personal favourite - change success of form to redirect to the same page, append a custom query string such as success=true then use liquid to only render the content snippet and form if the success doesn't equal true (you would need to display your own success message)
Prevent default action of the form and submit it yourself with javscript. I have done this before and it's a bit fiddly, probably wouldn't recommend for a simple use case like this.

How to store text from field with Google Tag Manager on a form submission

I'm trying to catch email address as a variable with Google Tag Manager (GTM) on signup form submit on http://cloud.feedgee.com/ru/signup and fire a tag with it. On submit, the page is being reloaded.
By now tried to catch it with Form submission by form id set as shown on screenshot) and a Button click as a Custom event with it's click id
I initiated a DOM element variable with Id of the Form text field (Element Id=ContentPlace_loginEmail)
With these settings in Preview mode on Form Submit, I can not see my Tag in "Tags Fired On This Page" row before page reload.
What can be the reasons for this if Id's of the elements are correct?
May it depend on the container script location on the page?
Now It's located right after the HTML tag.
Can I store form text field in a DOM variable to use it in the tag?
If you want to store the email value in your own API, Google Tag Manager is not the right tool for you. You should only use it to track events that fit under Google's terms of use.
Having said that, when you're working with forms in GTM, hold the <shift> key with you click the submit button. If you do that, a new tab will open up, but the current page wont get redirected or refresh. You'll then be able to see what data is being pushed to the dataLayer.

Auto send form (JSP) and load page in iframe

I have a page (jsp) with a form and a submit button. After clicking the button the form data is posted to another JSP that creates the output (a table with links).
My problem is, I need to do this AUTOMATIC, I can fill the form via url GET thats not the problem but how can I force the post to that other page without clicking a button. I want to include the result (table with links) on another page (with php or just iframe) so the result has to be generated when the page is opened.
I CAN NOT change any of the JSP pages, they are part of a closed system which I can't change.
Thanks...

Blue Imps jQuery file upload send files with form like normal field

Is it possible to send file with form as normal file upload? When I check a file field it is always empty, and I need to send it with form data in one call. IS that possible?
There might be better answers out there, but I ended up solving this by following steps.
Having 2 forms on the page. One for file upload and one for other form data.
Format both forms using CSS so that user gets look and feel of one form.
Have only one div (which looks like button) to submit. Hide the actual form's submit button, if you are using them (I don't. Because I preprocess data and then send by ajax)
Once user submits forms (by clicking the dummy button), Using JS programatically click the file upload button.
Optional Once that call is finished, if there are no errors only then continue.
Submit the form with other form data.
The advantage I had in this approach was that I could have more control over user's form data as well as my file upload's settings. Because I had some settings (like max number of files and max file size) were dependent on user's form entry.

Form submit to iframe on new page

I have a form which submits to an iframe, This works fine if you are on a page with the iframe.
I want to be able to have the form on any page and when submit is pressed load a page and send the submit to the iframe
e.g.
On page "article.php" and press submit
Open page "results.php" and
Send post data from form clicked in "article.php" to iframe "DataHere" on "results.php"
Thanks in advance
You could try detecting if the frame exists when the form is submitted and if it does not, reload the whole page and generate the iFrame.
If you need a hand checkout http://www.java-scripts.net/javascripts/Check-Frames-Page-Script.phtml
If you are able to comfortably sanitize your initial POST data to avoid XSS, you could create an intermediate page for your iframe destination that does your POST for you:
On page article.php with <form action="results.php">, press submit.
results.php validates that the input isn't XSS, and renders with a <iframe src="negotiator.php?my=form&data=here"></iframe>
negotiator.php takes the query string arguments (and runs the same sanitizing as results.php) and POSTs them to your intended url.
Your results will load in the iframe.
It's pretty important that you make sure your input isn't insane. If your form requires arbitrary text, punctuation, and special characters, this is not safe for you.