Make link using submit button - html

Can I link one page to another page using submit button?

It sends all the wrong signals to the user, but:
<form action="some-uri"><div><input type="submit"></div></form>

The problem with using a submit form is that the next page will think that it has to deal with a binary request, which you can't do if using an upload form.
So you are better using a image button (can make it look like a submit button) or using JavaScript...
Open in a new window:
onClick="window.open('page.html');"
Open in the same window:
onClick="document.location.href = ('page.html');"

Related

How to show the upload file dialog on page load

Using PF10 (in a JoinFaces project), I'd like the Upload File dialog for choosing a file to show up when the page loads (i.e., without waiting for the user to click on the Choose button of <p:fileUpload/>). How can I do that?
You could use client side API show() function for this. But it seems more and more browsers are blocking triggering a click by script on an input type="file". See https://github.com/primefaces/primefaces/issues/7772
You could take your chances and try to hijack a mouse move event to trigger a click on the upload input, which is answered on this question: In JavaScript can I make a "click" event fire programmatically for a file input element? But I don't really like that hack.

Unexpected form submit

I faced with a strange problem. I write ASP.NET web application.
I have form tag on the aspx page and submit in the form. When I click on the submit form's data are posted. It is ok. But if I close the page right after submit and then re-open it with Main Menu -> Recent Tabs (I use Google Chrome) the form's submit fires once again and data are posted too. I would like to avoid this behavior because repeated posting data to server is unwelcome and unexpected. It happens after select Recent Tabs only (when I prress Ctrl+Shift+T it does not happen) How could I prevent it? Thanks in advance
Check if it's a PostBack. If it is a PostBack then return.

Form data re-appears on pressing back button in browser

I have a form on a webpage that submits post information to the server. All is working good except when i submit the form and press back button the data in the form re-appears instead of going to the previous web page. How can I prevent this? Also I want the previous web page to be reloaded again when i press back button.
Thank you.

Using a button as a link in HTML (form ASP.Net MVC 3)

My input pages have an OK and a Cancel button on them. These buttons are generated in a separate, partial view. The OK button is the submit for the form. The Cancel is a link to a different action. I can't make the Cancel button into a standard:
<form><input value="Cancel"></form>
as this would end up with nested forms which doesn't work (The form is on the outer, master view).
I can use Javascript, but I was hoping to have a page that would work without it.
I tried:
<button type="button">Stuff</button>
This works fine on Firefox, but does nothing on IE. Am I missing something here? Is there a simple way to get a button to work as a hyperlink?
You can always make the cancel button submit the form and make the redirect on the server side
you could CSS-style your link to look like a button.

Error with IE and form data when clicking back

Say if I am on page 1 , I enter my form data and go to page 2 , But wait I forgot something and I need to go back. FireFox and Safari ask me if I want to resend my form data.
But IE being IE it just goes back and does not show the page.
Is there away around this when I click back it keeps the data and the page appears.
Sorry I cannot give a link but the process for u to go through on my site to get to this part would take you a while.
My suspicion is that your talking about a wizard form. Where each part of the form is a page and you can go backwards and forwards through the pages.
the back button has always caused problems for developers on the web and this is probably the most annoying.
You can stop the IE back button issue by redirecting on the server to the next page when you receive a form post rather than just delivering the form back to the browser. Doing this means that the browser considers each page to have been a get and stops asking you if you want to resubmit the form.
to do this simply make each form post to itself and then return a redirect to the next page of the wizard. I'd give examples but I'm not sure what language you are using on the server.
the other alternative is to use javascript to create a wizard from your form see this jQuery wizard form demo.
create a new back button besides the submit button and when a user clicks on either one you call a javascript function which modifies the form action either to the next page or the previous page.