lundi 18 octobre 2021

Checkbox checked on load and input box filled when a value present

I have created a sandbox::

https://codesandbox.io/s/sweet-agnesi-qbf7g?file=/src/components/HelloWorld.vue

So my basic query is let say I have an array of object present as:

  let sampleArrayOfObject = [{
    Item: "ACC",
    Price: 12,
  },
  {
    Item: "BCC",
    Price: 50,
  },
  {
    Item: "ECC",
    Price: 21,
  }]

I have input field of type checkbox and text,

in checkbox let say I have ACC, BCC, CCC, DCC, ECC.

Let's say when sampleArrayOfObject matches with the checkbox field, ACC,BCC,CCC,DCC,ECC all the matching value present in sampleArrayOfObject should be checked and input field of type should have Price as value.

When checkbox is clicked, input field of type text should be visible where we can input the value.

So we should be able to remove the present value or change the price value and all those values should be store in newItem variable (detail on this variable present in codesandbox) on click of submit.

I tried but I am stuck, please let me know if anyone needs any further information or need any further clearance.




Aucun commentaire:

Enregistrer un commentaire