+ 1

what is the function of value attribute in <input>?

10th Jul 2016, 1:12 PM
yogesh
yogesh - avatar
4 odpowiedzi
+ 1
@marco The 'name' attribute is submitted with the form data. 'value' is optional except when 'type' attribute is checkbox or radio.
12th Jul 2016, 12:35 AM
ZinC
ZinC - avatar
0
it's the value that will be processed after the submission. As for example <input type="radio" value="NAME1" /> <br/> <input type="radio" value="NAME2" /> After submitting, if the first choice is selected by the user, the NAME1 value will be processed.
10th Jul 2016, 2:17 PM
marco
0
It depends on 'type' attribute. If the type is "text, the 'value' is optional and could be used like a placeholder that should be replaced by the user with the real value. Example: <input type="text" name="firstname" value="Joe"> It's the 'name' attribute which gets processed in this case. In the case of using <input> as a submit button, the value "Submit" is what the button text will be. It could also be a 'Reset' or 'OK' button.
10th Jul 2016, 4:41 PM
ZinC
ZinC - avatar
0
zinc... your answer isn't 100% correct.. the "value attribute" gets always processed.. name attribute is just a "name" for that data entry. In the case that you highlighted, the "value" is not optional... it is just or defined by the user or defined in the code
10th Jul 2016, 5:45 PM
marco