lundi 20 juillet 2020

How to set auto increment +1 from last row numeric value

Here is my code examples. first line "end_no = 10" I need to add +1 from "end_no" to second line "start_no".Second line "start_no" should be 11 then auto add +1 from each line start_no. How to set the code? Please help me.

```
export default{
     data(){
      return{
        form:{
        items:[]
      },
    }
  },
  methods:{
    addNewLine(){
      this.form.items.push({
       start_no:1,
       end_no:10,
      })
    },
  }
}
```
```<div>
   <button @click="addNewLine">Add New Line</button>
</div>
```
```
<form>
   <table>
       <thead>
           <tr>
             <th>SL.</th>
             <th>Name</th>
             <th>Start No</th>
             <th>End No</th> 
           </tr>
       </thead>
       <tbody>
           <tr v-for="(item , index) in form.items">
             <td></td>
             <td><input type="text" v-model="item.start_no" /></td>
             <td><input type="text" v-model="item.end_no" /></td>
           </tr>
       </tbody>
    </table>
</form>
```


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire