Convert value of a select options component to number

Asked

Viewed 72 times

0

I have a component select and would like to convert the value for the format Number 'cause when I go save I need a value 2 and not like this "2"

the ideal would be to convert all tag <option>

          <div class="form-group col-md-3">
              <label class="lb">Tipo docto liquidação:</label> 
              <select ng-model="notaLiquidacao.idTipoDoctoLiquidacao"  class="form-control" >
                <option  value=2>Nota Fiscal de Produtor</option> 
                <option  value=3>Nota Fiscal</option>
                <option  value=4>Contranota de Venda</option>
                <option  value=6>DANFE</option>                   
              </select>

            </div>
  • 1

    Have you tried parseInt?

  • I tried but I couldn’t convert them all value

  • because it is angular... if you have the attribute typed in your model, theoretically it should already interpret value as number

  • yes, but when I get the object information is in the String format

1 answer

0

Use the parseInt()

<script>
  var meuNumber =  parseInt($(".form-control").val());
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.