简体   繁体   English

如何在每个for循环的输入字段中加1的id?

[英]How can I add id by 1 for input field in each for loop?

My current html code is: 我当前的html代码是:

<div id="app">
   <div class="row" v-for="(book, index) in seziure" :key="index">
      <div class="col-md-8">
         <div class="form-group label-floating">
            <label class="control-label"> Details</label>
            <input type="text" class="form-control" v-model="book.details" id="'transliterateTextarea'+(index+1)">
         </div>
      </div>
   </div>
   <a @click="addNewRow">Add Another</a>
</div>

But I think id is not changing. 但我认为id不会改变。

What is the error in that. 这是什么错误。 Actually I am looking for transliteration id's to be changed for each input fields. 实际上,我正在寻找每个输入字段要更改的音译ID。

I am able to change transliteration ids by the following code: 我可以通过以下代码更改音译ID:

<script type="text/javascript">
    function transliterateInit(idNo) {
        // Load the Google Transliterate API
        google.load("elements", "1", {
            packages: "transliteration"
        });

        var options = {
            sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
            destinationLanguage: [google.elements.transliteration.LanguageCode.MALAYALAM],
            shortcutKey: 'ctrl+g',
            transliterationEnabled: true
        };

        // Create an instance on TransliterationControl with the required
        // options.
        var control =
            new google.elements.transliteration.TransliterationControl(options);

        // Enable transliteration in the textbox with id
        // 'transliterateTextarea'.
        var ids = ["transliterateTextarea" + idNo];
        control.makeTransliteratable(ids);
    }
</script>

My vue js code is: 我的Vue JS代码是:

addForm = new Vue({
    el: "#addForm",
    data: {
        seziure: [{
            details: null,

        }, ],
        mounted: function () {
            transliterateInit(1);
        },
        methods: {
            addNewRow: function () {
                this.seziure.push({
                    date: null,
                    details: null
                });
                transliterateInit(this.seziure.length);
            }
        }
    }
});

I have able to update transliteration id's. 我能够更新音译ID。

I AM NOT ABLE TO UPDATE ID's in the input fields. 我无法在输入字段中更新ID。 Please help me to update id's in the input field. 请帮助我更新输入字段中的ID。

您需要将transliterateTextarea数据放入Vue实例的数据中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在PHP中如何为while循环中创建的每个输入文本框生成动态ID - in php how can i generate dynamic id for each input textbox created in while loop 如何遍历表单ID列表并为每个表单添加提交处理程序? - How can I loop through a list of form ID's and add a submit handler to each? 如何添加逗号来分隔文本输入字段中的每组三位数? - How can I add a comma to separate each group of three digits in a text input field? 我如何在while循环中添加输入id值(基于迭代),该while循环引用其中的一段html? - How can I add an input id value (iteration-based) in a while loop that references a piece of html outside of it? 如何为数组中的每个对象添加唯一 ID? - How can I add a unique ID to each object in an array? 如何在不同的输入字段中添加每个学生的 ca 和考试分数,并在单独的文本字段中显示他们的总分 - How can I add each students ca and exam score in different input Fields and display their total in separate text field 如何使用JavaScript将字段添加到数组的每一行? - How can I add a field to each row of an array with Javascript? 如何在JavaScript中向输入字段添加ID - How to add ID to input field in javascript 如何为每个循环将我的JavaScript添加到我的php中? - How can I add my javascript to my php for each loop? 如何在输入字段中已经存在的字符串的末尾添加? - How can I add to the end of the string that already exists in input field?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM