What should an HTML value attribute contain?

0

From a maintainability and organization perspective what should a value attribute contain? a number representing a word:

<label><input type="radio" name="order" value="1">Masculino</label>
<label><input type="radio" name="order" value="2">Feminino</label>
<label><input type="radio" name="loja" value="1">Ricardo Eletro</label>
<label><input type="radio" name="loja" value="2">Submarino</label>
<label><input type="radio" name="loja" value="3">Casas Bahia</label>

or content ready to be inserted / searched in the database for example:

<label><input type="radio" name="order" value="Masculino">Masculino</label>
<label><input type="radio" name="order" value="Feminino">Feminino</label>
<option value="MaisCaroPrimeiro">Mais caro Primeiro</option>
<label><input type="radio" name="loja" value="RicardoEletro">Ricardo Eletro</label>
<label><input type="radio" name="loja" value="Submarino">Submarino</label>
<label><input type="radio" name="loja" value="CasasBahia">Casas Bahia</label>

When and where should the conversion be made to the actual value?

    
asked by anonymous 20.04.2015 / 20:30

2 answers

3

The value is the information that will be sent to the server, can be used 1, 2, f, m, masculino, feminino , whatever. Because it is you who will receive this information and treat the use of it. In W3S I found this example using text input that should clarify your question a bit.

But in the end when the server receives the response of the button marked it will receive the value indicated in the attribute value , simple as well.

    
20.04.2015 / 20:44
2

In the case of the "radio", the value determines the value of the response ... It can be either 1.2 / Male, Female / M, F. It depends on how you will treat it later.     

20.04.2015 / 20:34