What do the empty quotations mean for value?


Joined
Aug 31, 2022
Messages
8
Reaction score
0
Do the empty quotes mean that multiple values can be entered for the value?

HTML:
<input name="favoriteCities[]" value="" />
 
Ad

Advertisements

Joined
Mar 11, 2022
Messages
129
Reaction score
13
Means "here comes an array".

Before submit
Code:
 <input type="checkbox" name="myArray[]" value="A" checked>
<input type="checkbox" name="myArray[]" value="B" checked>
<input type="checkbox" name="myArray[]" value="C">
<input type="checkbox" name="myArray[]" value="D" checked>
<input type="checkbox" name="myArray[]" value="E">
<input type="checkbox" name="myArray[]" value="F" checked>

After submit in PHP
Code:
echo '<pre>';
print_r($_POST[myArray]);
echo '<pre>';

Output:
Code:
myArray{
  [0] => A
  [1] => B
  [2] => D
  [3] => F
}
 
Ad

Advertisements

Joined
Jul 12, 2020
Messages
33
Reaction score
2
The value attribute can be used as a default placeholder or a preset value for the field. When the field is selected the default value is then highlighted and can be changed by the individual. Other than that, the "value" attribute is not required to process the form, the input entered will still be submitted.

HTML:
<input name="favoriteCities[]" value="" />

<input name="firstname" value="Enter Your Name" />

<input name="firstname" />

Note: It was used as a placeholder for many years until the created the new "placeholder"
attribute for some reason, kicks and giggles I guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top