0
I’m trying to get the value of the date field of a select, but I’m not getting it. Only the default value field I’m getting.
The field in select this as: "data-value2"
Using . valor2
HTML:
<select
onchange="verificaHierarquia(this)" class="form-control"
id="hierarquia" name="hierarquia.id">
<option value="" data-valor=0 selected>SELECIONE...</option>
<c:forEach var="hierarquia" items="${hierarquias }">
<option value="${hierarquia.id }"
data-valor2="${hierarquia.nivel }">${hierarquia.descricao }</option>
</c:forEach>
</select>
Could you add your HTML to the question? Remember that the site has source code support, just use the button
{}
of the editor.– Woss
@Andersoncarloswoss added
– Kennedy Anderson
So what you need is to take the value of
data-valor2
of the element<option>
, not of<select>
?– Woss
The ideal would be the rendered html, what you mean by data-value, you refer to data-value2 ?
– Leandro Angelo
Yes data-value is data-value2.
– Kennedy Anderson
I did a test just putting " = value2;" and it worked I will test other situations.
– Kennedy Anderson
@Andersoncarloswoss tried the solution of this question, and it did not work.
– Kennedy Anderson
To change the value of a "date" attribute in Jquery?
– Woss
@sam has already solved it.
– Kennedy Anderson
Blz! Success there.
– Sam