Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Vue jS: input auto filled

In my Vue JS code below i have input total price and two inputs paid and percentage, i wanted to do an algorithm that what ever user wrote inside paid input an auto percentage should be filled in percentage input and ofc this percentage is from total price input, also when user write in percentage input the paid should be auto filled and so on.

Is there a way to do this in Vue js?

P.S: I wrote v-model=instpaid and v-model=instprice that posts data to API

<input type="number" v-model="instPrice" class="price-input mt-3" placeholder=" total price" required />
<br />
<input type="number" v-model="instPaid" class="price-input mt-3"                                                                placeholder=" paid " required />
<input type="number"  class="price-input mt-3" placeholder=" percenatge"                                                                  required />

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Maybe something like following snippet:

new Vue({
  el: "#demo",
  data() {
    return {
      instPrice: 0,
      instPaid: 0,
      pct: 0
    }
  },
  methods: {
    calc(pct) {
      pct === true ?
        this.instPaid = (this.instPrice / 100 * this.pct).toFixed(2)
      :
        this.pct = (this.instPaid / this.instPrice * 100).toFixed(2)
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <input type="number" v-model="instPrice" placeholder=" total price" required />
  <br />
  <input type="number" v-model="instPaid" placeholder=" paid" @keyup="calc(false)" required />
  <input type="number" placeholder=" percenatge" @keyup="calc(true)" v-model="pct" required />
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda