how to determine html input files sequence - html

So, let's say this is the code I used in my html from W3CSCHOOL
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
Select images: <input type="file" name="img" multiple>
<input type="submit">
</form>
<p>Try selecting more than one file when browsing for files.</p>
<p><strong>Note:</strong> The multiple attribute of the input tag is not supported in Internet Explorer 9 and earlier versions.</p>
</body>
</html>
The action_page.php is going to display the files you have selected. But it will display it by name orders, not the selection orders. I am wondering if there is anyway to change the sequence of the file? Maybe based on the selection order?

There is no selection order.
The files are all being chosen all together.
You can dynamically add more image inputs as far as the user asks for.

Related

Input type=time is not working with min and max attributes

This question might be asked many times. But there is no clear explanation whether it is possible or not.
I have a input with type="time". I have applied min and max attributes to it. But still the picker shows all the time values and it is also possible to select any time value which not in the range.
<input type="time" id="gfg" name="Geek_time" placeholder="Enter time" min="16:00" max="22:00">
I'm checking this on android phone. This also does not work in web chrome browser.
Whereas it works fine with input type="date"
Is this behaviour expected with time input?
Only JS based validation works here and not in-built min/max?
Below is a very simple html code. Once the html is rendered, you can enter any value you like but the form will not go through. Your browser has to be compatible. Check browser compatibility.
<html>
<head>
</head>
<body>
<form>
<input type="time" id="gfg" name="Geek_time" placeholder="Enter time" min="16:00" max="22:00">
<input type="submit">
</form>
</body>
</html>
I tried entering values outside the range (less than 16:00 or more than 22:00) and then submit the form. It gave errors.

Use HTML5 to check inputs in quiz style format

I am trying to use HTML5 to offer some sort of live quiz on a webpage. I am not interested in submitting or storing the user inputs on a server, I just want to show the user a direct feedback on whether his inputs are correct or not. I want to use pure HTML5 and a purely client based evaluation, without any javascript or server evaluation.
Unfortunately, I am no HTML expert at all. The HTML5 code I have come up with so far is the following:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Exercise</title>
<style>
/*An incorrect input:*/
input:invalid{
color:red;
}
/*A correct input:*/
input:valid{
color:green;
}
*/
</style>
</head>
<body>
<p>
Complete the missing words using information from the following template:
<ol>
<li> This is a first test.
<li> This is a second test.
</ol>
<p>
<form action="#.ext" method="post" id="myform">
<ol>
<li>
<label for="GM">This</label>
<input required
type="text"
id="GM" name="GM"
pattern="is">
<label for="GM1"> a </label>
<input required
type="text"
id="GM1" name="GM1"
pattern="first">
<label for="GM2"> test.</label>
<li>
<label for="GM3">This is a </label>
<input required
type="text"
id="GM3" name="GM3"
pattern="second">
<label> test.</label>
</ol>
</form>
<button form="myform" type="submit">Check and show correct solutions.</button>
</body>
</html>
The HTML5 is already capable of checking inputs against a pattern which contains the correct solution and the change the color of the input element from red to green if the solution is correct.
What I have not managed to achieve so far:
I'd like the checks for all inputs to start only when the button is pressed (but without submitting the inputs to the server, I want to check locally against the patterns.)
I'd like to see correct solutions in all input fields as soon as the button is clicked, even if they have been empty before (however I cannot use the placeholders for that because they would be visible from the beginning)
I'd like to change to colors of the forms only after the button is clicked (e.g. red if solution was wrong and green if it was OK)
In the best case I'd like to additionally add the wrong user input in red and crossed out plus the correct input in green in one input field.
I am fully aware that I am not using those tools the way they are usually intended to be used, since I am not interested in actualy submitting the content of the input fields to the server.
Thanks for any feedback.

HTML Input Multiple Tag

I have a simple HTML form that I am building. I want to be able to added multiple files to submit with the form to upload. Everything I am reading online about HTML5 says that I am able to do this with the HTML5 Input Multiple tag. When I try this in any browser I get the standard Input with a type of file. When I inspect the DOM i see that it has only a single file in it's Files[0] attribute. Here is my form. Please let me know what I am doing wrong.
Here is my HTML for the the form for uploading files:
<form method="post" action=upload.php" enctype="multipart/form-data">
<input type="file" id="basicUploadFile" multiple >
</form>
Also. I have tried this in Chrome, Firefox, IE 11. Even going to the W3school.com demo doesn't seem to work in any of them for multiple files.
files[0] will show you the first file selected. files gives you a collection of the selected files, files.length gives you the number of files selected. So once you select more than one file if you console.log(fileinput.files) you'll see multiple files logged.
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="file" id="UploadedFiles" name="UploadedFiles[]" multiple>
<input type="submit" value="SendFile">
</form>
in upload.php analize structure of array $_FILES ;)
good like!
Is that a typo? There is a " missing before the upload.php
your form tag looks correct
http://en.wikipedia.org/wiki/File_select#Multiple_file_selection
[edit]
If you are referring to the W3schools site, this works for me on Chrome and IE
http://www.w3schools.com/tags/att_input_multiple.asp
TryIt site:
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_multiple

Chrome not prefilling form

I have a form that I would like to have chrome autofill or prefill (I'm using Mac Chrome 26.0.1410.65 on Mountain Lion). The purpose of this is to demonstrate the autocomplete standards: I'd like to show either the fields prefilled on load, or if the user starts typing their first name it will auto-fill both names.
I'm using autocomplete and the entire page is below, with just two fields.
I submit, then the next time I visit the page, I have to start typing into each field to get the drop-down for auto-complete. No matter what I do on the first field, I have to tab to the second and start typing there.
I'd like it to fill in all the fields (well, both) when I accept a value in the first field. How do I get that? I see it happening in commercial websites, where starting to type in a single field and it pre-fills many other fields. (even if there is a yellow background)
<!DOCTYPE html>
<html>
<head><title>Autofill test</title></head>
<body>
<form name="nameform" action="?go" method="POST">
<input type="text" name="givenname" autocomplete="given-name">
<input type="text" name="familyname" autocomplete="family-name">
<button type="submit">Save values</button>
</form>
</body>
</html>
I've seen the other questions that indicate I have to use POST, and there cannot be hyphens in the name. I have also tried x-autocompletetype and autocomplete. I've also tried without the DOCTYPE (I'm getting desperate), and renaming the fields "fname" or "firstname" etc. Nothing appears to work.
Is there something I'm missing?

HTML Forms & control names

So I was having issues with the form / hidden iframe file upload technique and spent several days trying to figure out why files wouldn't upload until finally figuring out what the issue was.
When I am building the form dynamically, I insert the file input element as a child of the form:
<input type="file" id="file-select-input" />
... and I had something like this:
<form enctype="multipart/form-data" id="file-select-form" target="select-file-iframe" method="POST" action="/upload/">
<div id="file-select-button" class="">
<input type="file" id="file-select-input" />
</div>
</form>
<iframe style="display: none" id="select-file-iframe" src="javascript:false;" name="select-file-iframe"></iframe>
It turns out that when I submit the above form, the input file information was not being sent. The reason for this, is that I didn't have the name attribute specified on the file input element. So when I changed it to this:
<input type="file" id="file-select-input" name="file" />
... things worked.
So why does the name attribute of an file input element need to be set for a file to be uploaded? According to the W3C specs, the name attribute assigns the control name, but what is the control name? Why is it important?
According to the W3C specs, the name attribute assigns the control name, but what is the control name? Why is it important?
The name of the form control controls the key in the key/value pairs that make up the POSTed data or the query string.
Without knowing the name of the control, there's no way to transform it into the data to be sent to the server.