Does Form Data Still Transfer If the Input Tag Has No Name

Does form data still transfer if the input tag has no name?

The W3C specification, if I understand it correctly, mandates that every form input element has a name attribute specified. Otherwise that element will not be processed. Source

Can you get a forms submitted data even when the input element has no name?

Browsers do not send POST data for elements if they have no name. Therefore you cannot get the values of the inputs.

What is the point of input without name in HTML5?

Not all input is used server-side. In many cases it's used for form submission via AJAX. Additionally, a JavaScript app can make use of user input without ever needing to use a form.

Html form posting, no data passed on

You should be using the name attribute of input to send the data to a PHP post script. Example:

Form:

<form action="add.php" method="post">
<input type="text" name="firstname" />
</form>

Script (add.php):

<?php
//print the $_POST['firstname'] variable
echo $_POST['firstname'];
?>

Not getting entered data from input element

If you are letting the form submit itself with the inputs from your function, then the problem is that you have not set a name attribute for those inputs. Just give them a name.

Unnamed inputs do not get processed see this answer for further details https://stackoverflow.com/a/12543907/6127393

Stop an input field in a form from being submitted

You could insert input fields without "name" attribute:

<input type="text" id="in-between" />

Or you could simply remove them once the form is submitted (in jQuery):

$("form").submit(function() {
$(this).children('#in-between').remove();
});


Related Topics



Leave a reply



Submit