我有两个选择框。仅更新第二个选择。
如果我删除ff.add
tf.add
有效。
function copyToFrame(selectedOption) {
if (selectedOption == "New") {
var tf = document.getElementById("sCopyToFrame");
var option = document.createElement("option");
document.getElementById('copyToFrameCounter').value = parseInt(document.getElementById('copyToFrameCounter').value) + 1;
option.text = "Frame " + document.getElementById('copyToFrameCounter').value;
tf.add(option);
var ff = document.getElementById("sCopyFromFrame");
ff.add(option);
}
}

<INPUT type="hidden" id="copyToFrameCounter" value="0">
<p> Copy to frame:
<select id="sCopyToFrame" onchange="copyToFrame(this.value);">
<option selected disabled hidden style='display: none' value=''></option>
<option>New</option>
</select>
</p>
<p> Copy from frame:
<select id="sCopyFromFrame">
<option selected disabled hidden style='display: none' value=''></option>
<option></option>
</select>
</p>
&#13;
答案 0 :(得分:0)
a) Handler
b) Alarm Manager
c) JobScheduler
d) Firebase JobDispatcher
e) SyncAdapter
f) ..anything else if there is...
&#13;
function copyToFrame(selectedOption) {
if (selectedOption == "New") {
var tf = document.getElementById("sCopyToFrame");
var ff = document.getElementById("sCopyFromFrame");
var option = document.createElement("option");
var optionCopy = document.createElement("option");
var cTFC = parseInt(document.getElementById('copyToFrameCounter').value) + 1 || 0;
option.text = "Frame " + cTFC;
optionCopy.text = "Frame " + cTFC;
tf.add(option);
ff.add(optionCopy);
}
}
&#13;
答案 1 :(得分:0)
如果要为两个下拉列表添加新选项,则需要两个元素
function copyToFrame(selectedOption){
if(selectedOption == "New"){
var tf = document.getElementById("sCopyToFrame");
var tf_option = document.createElement("option");
document.getElementById('copyToFrameCounter').value = parseInt(document.getElementById('copyToFrameCounter').value) + 1;
tf_option.text = "Frame " + document.getElementById('copyToFrameCounter').value;
tf.add(tf_option);
var ff = document.getElementById("sCopyFromFrame");
var ff_option = tf_option.cloneNode(true);
ff.add(ff_option);
}
}