Question / Problem
I want to add a text box every time I click the button.
My custom button disappears when I save it.
(function() {
'use strict';
kintone.events.on('app.record.create.show', function(event) {
// Create the first button
var button1 = document.createElement('button');
button1.id = 'button1';
button1.innerHTML = '計數';
// Run code when the button is clicked
button1.onclick = function() {
// Create text box
// 生成文本框
var textField = document.createElement('input');
textField.type = 'text';
textField.placeholder = '输入计数值';
// Add text box to space element
// 将文本框添加到空间元素中
kintone.app.record.getSpaceElement('btn1').appendChild(textField);
};
// Set button1 on the first Blank space field
kintone.app.record.getSpaceElement('btn1').appendChild(button1);
// Create the second button
var button2 = document.createElement('button');
button2.id = 'button2';
button2.innerHTML = '計量';
// Run code when the button is clicked
button2.onclick = function() {
var record_data = kintone.app.record.get();
alert(record_data.record.Created_datetime.value);
};
// Set button2 on the second Blank space field
kintone.app.record.getSpaceElement('btn2').appendChild(button2);
// Create the third button
var button3 = document.createElement('button');
button3.id = 'button3';
button3.innerHTML = '測缸計';
// Run code when the button is clicked
button3.onclick = function() {
var record_data = kintone.app.record.get();
alert(record_data.record.Created_datetime.value);
};
// Set button3 on the third Blank space field
kintone.app.record.getSpaceElement('btn3').appendChild(button3);
// Create the fourth button
var button4 = document.createElement('button');
button4.id = 'button4';
button4.innerHTML = '測相異位置';
// Run code when the button is clicked
button4.onclick = function() {
var record_data = kintone.app.record.get();
alert(record_data.record.Created_datetime.value);
};
// Set button4 on the fourth Blank space field
kintone.app.record.getSpaceElement('btn4').appendChild(button4);
});
})();