html submit button stays on the same page - html

I am writing a mobile app in html5/css/js.
On the first page index.html I made a form with a submit button that point to result.html (with formaction="result.html").
But when I open index.html in Chrome just to debug the app, the submit button doesn't bring the user to result.html, but stays on index.html.
What's wrong?
Thanks
<form name="userdata" method="get">
<input type="number" step="any" class="hiddenbutton" name="userVolume" value="" >
<button type="submit" id="submitbutton" name="issubmitted" value="no" class="submitbutton" formmethod="get" formaction="result.html">Submit</button>
</form>
It doesn't work neither with:
<form name="userdata" method="get" action="result.html">
<input type="number" step="any" class="hiddenbutton" name="userVolume" value="" >
<button type="submit" id="submitbutton" name="issubmitted" value="no" class="submitbutton">Submit</button>
</form>
EDIT: I just discovered that there is no problem when I use firefox instead of Chromium (Ubuntu). Any hint on what's happening?

I think you need to explicitly state that as an attribute, i.e. an 'action' attribute in 'form'.
<form name="userdata" method="get" action="result.html">
<input type="number" step="any" class="hiddenbutton" name="userVolume" value="" >
<button type="submit" id="submitbutton" name="issubmitted" value="no" class="submitbutton" formmethod="get" formaction="result.html">Submit</button>
</form>

I removed all the action and formaction attributes to the form and submit button, and I decided to code my page as an SPA (single page app) so I move to next page using jquery:
$.mobile.changePage($('#result-page'));

Related

Sending an email using HTML form

Here is my code.
<form action="MAILTO:example#gmail.com " method="post" enctype="text/file">
A3 or A4:<br>
<input type="text" name="A3 or A4"><br>
Add image:<br>
<input type="file" name="image"><br>
<input type="button" id=" value="click">
</form>
Issue: After Clicking the submit button or in this case just the button, nothing happens. I am currently using gmail so if you could please help.
First, a button of input type="button" will not prompt the POST action. You should be using a submit button:
<input type="submit" value="click"/>
Second, form action="MAILTO: " should be form action="mailto:someone#example.com".
A simple example perhaps could provide some insights. Yet, as you mentioned Gmail usage, I suggested reading Gmail API Guides in which examples of various languages are provided.
The button should have type="submit"
<form action="mailto:" enctype="text/file" method="post">
A3 or A4:<br>
<input name="A3 or A4" type="text"><br>
Add image:<br>
<input name="image" type="file"><br>
<input type="submit" value="Send">
</form>

How do I add a query to a get request with HTML?

I have made this:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <input type="submit"><br>
Show: <input type="submit">
</form>
Is there any way I can pass a parameter when I press a different button? When I click now it sends me to links.php?link= which is good, but I want to do so that if I click one of the buttons, it sends me to links.php?link=&up=no.
I think I found a solution but it uses javascript, I want to do it with HTML only.
If you're looking to add a parameter based on what submit button was pressed, you can add a name to each of them:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <input type="submit" name="direct"><br>
Show: <input type="submit" name="show">
</form>
Pressing the direct submit button will give:
?link=&direct=...
Pressing the show button will give:
?link=&show=...
edit
In the event that you want to pass a specific value for each button (which isn't tied to it's text like a submit input is), use the button tag instead of the input tag and pass it explicitly:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <button name="direct" value="foo">Submit</button><br>
Show: <button name="name" value="bar">Submit</button>
</form>
which would result in: ?link=&direct=foo and ?link=&show=bar

How to set button's label without changing value in post

I've got this code in html:
<form action="/login/" method="post">
<input type="text" name="login">
<input type="text" name="pass">
<input type="submit" value="login" name="type" >
<input type="submit" value="register" name="type" >
</form>
When I submit this form it sends a get request with the value of the field of the button clicked. However I want to change the label of the button without changing the value sent in get. Is it possible or not?
Use a button element:
<button type="submit" name="type" value="register">Sign up for an account</button>
Note that old IE has problems with this.

Two submit buttons

I have two forms on a same page and I have two submit buttons...so how do I check if the user filled out the first form before clicking the submit button on second form? The first form posts the data to php page which presents on a same page as the html and the second form sends the data to another PHP page with thank you message....I mean how do force the user to finish the first form before clicking the submit button on the second form? if the user hits the submit button on the second form, the form directs to thank you page with out checking if the user finished the first form..how do I stop that?
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="submited" value="true" />
<label for="file">Choose Photo:</label>
<input type="file" name="file" onchange="file_selected = true;" required>
<input type="submit" value="Submit" name="submit">
</form>
<form action="Send.php" method="post">
First Name:<input type="text" name="fname" required><br>
Last Name:<input type="text" name="lname" required><br>
Choose Username:<input type="text" name="username" required><br>
Age:<input type="text" name="age" required><br>
<input type="submit" value="Submit" name="submit">
</form>
You can change the name field and then access the value on the server side.
For example:
<input type="submit" value="Submit" name="submitOne" />
If you're using php you could use something like this:
if(isset($_POST['submitOne'])){ /* first one pressed */ }
There are also some other options like using jQuery or javascript to validate first.
Try: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

IE9 is auto-submiting form when <a> links clicked

While using IE9, every link (when clicked) the search form is being submitted. Every link seems as if it is redirecting to the action value of the search form.
There is no java script attached to the form element.
<form action="/my-search-url" method="post">
<input type="submit" value="search" />
<input type="text" value="" />
</form>
The issue was with the order of the form elements. Apparently the original developer decided to place the submit button before any input elements. By putting the submit input last (or removing it) fixed this issue.
<form action="/my-search-url" method="post">
<input type="text" value="" />
<input type="submit" value="search" />
</form>