![](/img/trans.png)
[英]AngularFire2 update creates new document field instead of updating a field
[英]i want to update an array with an input field, but instead it creates a new one
我想通過在輸入字段中輸入需要更新的內容來更新數組。 但不會更新,而是創建一個新數字。 我該如何解決?
這是代碼:
function appendInputs(param) {
param = param || '';
var inputfield = $('div.words div div div input.inputrule').last();
if (inputfield.length == 0) {
var amount = 0;
}
else {
var amount = inputfield.data('id') + 1;
}
//De vakjes van Cms.php
var html = '<div class="change"> <div class="col-md-2"> <input type="number" value='+mp3[param-1]+' class="form-control" id="inp' + result + '" oninput="magic(this.id)"></div> </div> <div class="form-group exerciserule" id="' + amount + '"> \
<div class="col-xs-10"><input id="exercise_details_rule' + amount + '" name="rules" data-id="' + amount + '" class="form-control inputrule" value="' +nummer_text[param-1]+ '" type="text"> \
</div> </div>';
result++;
//append html
$('#textList').append(html);
$('#exercise_details_rule' + amount).focus();
}
function magic(id) {
var solo = document.getElementById(""+ id +"").value;
var string = id;
var index = string.slice(string.length - 1, string.length);
//mp3[value] = solo;
mp3.push(solo);
console.log(mp3);
}
嘗試這個:
string.slice(string.length - 1, 1, string.length);
這將刪除最后一個元素,並在數組末尾添加一個新元素
但是我不確定您是否需要...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.