How to make submit form which goes to the same page in Joomla - module

I am making form with submit button in Joomla custom HTML and I would like to stay on the same page after I click on the submit button.
Is that possible? Thanks in advance.

Just leave the form action attribute out. This will post back to the same page. Have a look at this question and answer: Is it a good practice to use an empty URL for a HTML form's action attribute? (action="")

If "stay on the page" means that the page will not reload, or anoter page will be loaded, yes, thats quite possible. I think the best way of doing this is replacing the <input type=submit> with a <button>, which calls a javascript function that evaluates the form, submits the data via ajax, and notifies the user that the form was successfully submitted.

Related

Splunk submit button (submitButton) does not refresh dashboard if no inputs are changed

I have a dashboard with a submit button (submitButton). The search isn't run until the button is pressed which is exactly what I want (the search takes a long time). I don't want the search starting as the user changes the other dropdowns (time), environment (Prod vs. QA), etc.
HOWEVER, sometimes it would be nice to hit the submit button and perform the search again without changing any of the other fields (time, environment, etc.). In this case the submit button does nothing! I can tell the underlying data has changed via searches, but the dashboard is not updated. Simply changing any of the fields, doing a search, and then changing them back and searching again solves the problem, but surely the submit button should just work w/o this workaround?
Thanks
If "nothing" has changed, then Submit is supposed to "do nothing".
If you want to refresh the page with all the parameters as set, you should be able to click the URL bar and press return (so long as there are no hidden tokens, they'll all get set in the query portion of the URL).
Each panel in the dashboard should (automatically) have a refresh button you can click to refresh the display without changing inputs.
Unfortunately, this is intended behavior.
I also wish that the submit button would rerun dashboard searches. I opened a post on Splunk ideas about this issue:
https://ideas.splunk.com/ideas/EID-I-739
If you have a splunk.com account, you can vote for this idea.
I've browsed through Internet and found some solution that with some modifications worked for me fine
<form>
..
<html>
<style>
div.fieldset.dashboard-form-globalfieldset div.dashboard-element.html.dashboard-element-html {
display: inline-block;
}
</style>
Refresh
</html>
...
<form/>
so basiclu im refreshing page with all of its attributes and passing attributes values form current ones chosen using tokens. splunk code didn't like & so replaced it with & and it worked fine. <> - can be found in your splunk page address.

submit button not working when generated from AJAX

I got an ASP NET Core RazorPage having a button which asynchronously replaces a part of the given HTML using an AJAX request.
Besides some text content it renders another button which is intended to post back the side when clicked. It is surrounded by a form element.
However, clicking the button I receive an HTTP 400 with the information "This page isn't working" (Chrome). Other browsers like Firefox return an HTTP 400 as well.
The relevant HTML with the button which has been created by the AJAX call is the one below:
<form method="post">
<button class="btnIcon" title="Todos" id="btnTodos" formaction="PersonManagement/Parts/MyPageName?handler=PerformTodos">Execute action</button>
</form>
As the url exists (I doublechecked it using the browser with a simple GET) I wonder whether the issue could be due to some security settings along with the browser or is there anything I am perhaps missing out here?
Thank you for any hint
Two things here first add this attribute to your form asp-antiforgery="true", then send it's value to the server in your AJAX post request.
jQuery magic starts here :)
token: $('[name=__RequestVerificationToken]').val(),
Antiforgery is ON by default since .net core 2.0 (as far as I remember), so if you do AJAX post you need to send the antiforgery token with each request.
Let us know if it helps. Spread knowledge don't hide it just for yourself :P
Finally I came across a very interesting article from Matthew Jones at https://exceptionnotfound.net/using-anti-forgery-tokens-in-asp-net-core-razor-pages/ about Anti-Forgery Tokens in Razor pages. Worth reading, indeed.
However, independently from that article what solved my issue was simply not to add the <form .. element at the client-side, but already at the server-side. As there is no need for me to explicitly adding it at the client-side, but only the button itself, this is a solution for me which works properly.
A brief summary of my scenario now:
There is a Razor Page containing usual cshtml content along with a <form method="post"..
Some anchor elements also are included, one is triggering a JQuery AJAX call to the server
The JQuery call comes back from the server with some additional HTML including the post button which which I add to the existing HTML.
The button is being rendered inside the now already existing
Clicking the button causes the page to post back in the wanted manner and executes the handler as intended.
Thanks again Stoyan for your input and help with that.

submit form data to custom page for emailing

I created a custom form on a shopify page and when the submit button is pressed i want all the data within the form fields to go to another page that is a request form where the user would enter data and upon submission the data will be emailed instead of buying anything. How is this done in shopify? the page that i'm talking about is this one
https://pharaohmfg.com/collections/billiard-pool-tables/products/luxor-pool-table
You can redirect to another page with a custom form but the email will not be send since you are required to use /contact#contact_form as the form action.
One way to bypass that is to submit the form as a contact form and redirect the user upon form success. Please note that this way if you submit the form more than once you will get a google challenge for spam protection which is not user friendly.
Another way is to create a custom APP and using a proxy to submit to that page and handle the request from there.
Or an another option is to use a third party app of some sort and use their form builder ( hopefully allowing you to tie the product variants in some way to the actual form ).
There are free services like formspree that allows direct submissions to an email but I don't know what are the limits there.

Flattr button only shown after page reload

I've followed the instructions in here to add an embedded flattr button to my site but it's only being shown after reloading the page. This is the page: http://nipanipa.com/en/donations/new. Actually, if you visit that url directly, the button will be shown but if you visit it throught the "Donate" link in the header it will not! I get this behaviour in both Firefox and Chromium.
What am I missing? Probably this has something to do with my poor knowledge of javascript... :S
Thanks a lot!!
Your website (or framework if you are using one) is bundling all javascripts in to one neat package that is only loaded on the first page load. The flattr javascript is automatically triggered onLoad, but unless you are actually on the donate page during the initial page load, there will be no flattr button to initialize.
One way of solving this is to call FlattrLoader.setup() somewhere on the Donation page.
But since you are only interested in having one Flattr button for one url there is a much easier way to add it.
Remove all Flattr related code from your source code and then use the embed tool to generate the button specific html/javascript and paste that code where you want the button to appear.
Hope this helps :)

How do I modify Login page submit to call my custom function before the normal flow in Sharepoint 2010

I want to modify the login page of Sharepoint 2010 to change the normal flow during page submit. I want my custom function to be called, Validate it and go to actual submition of the page based on the validation result.
I have tried calling my custom function using onclientclick in the "asp: Button" tag. The custom function gets invoked, but I am unable to make the flow complete by sumbitting the login page. Once the custom function gets executed, the whole execution is stopped.
Please help me in solving it.
Thanks in advance.
I solved it my self. As mentioned I had added an extra submit button. SO when a user clicks the 'Sign In' button the custom function is called. On its success I made the original asp:button to click.