https://select2.org/programmatic-control/add-select-clear-items
https://blog.csdn.net/qq_38776922/article/details/78849069
https://blog.csdn.net/u012374381/article/details/72629233
https://www.cnblogs.com/makalochen/p/13229472.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| <script>
function select_iframe(pre1, pid, pre2, sid, m)
{
prr = pid.split(',');
srr = sid.split(',');
for (var i = 0; i < prr.length; i ++) {
var ttype = parent.document.getElementById(pre1+'_'+prr[i]).type;
if (ttype == 'select-one') {
var ops = parent.document.getElementById(pre1+'_'+prr[i]).children;
var html = document.getElementById(pre2+'_'+srr[i]).innerHTML;
for (oi = 0; oi < ops.length; oi ++) {
if (ops[oi].text == html) {
// parent.document.getElementById(pre1+'_'+prr[i]).options[oi].selected = true;
// ops[oi].selected = true;
// $(parent.document).find('#'+pre1+'_'+prr[i]).val(ops[oi].value).trigger('change');
$('#'+pre1+'_'+prr[i], window.parent.document).val(ops[oi].value).trigger('change');
var show_id = $('#select2-'+pre1+'_'+prr[i]+"-container", window.parent.document)[0];
if (typeof(show_id) != "undefined") {
show_id.title = ops[oi].text;
show_id.innerText = ops[oi].text;
}
break;
}
}
} else if (ttype == 'textarea') {
parent.document.getElementById(pre1+'_'+prr[i]).innerHTML = document.getElementById(pre2+'_'+srr[i]).innerHTML;
parent.document.getElementById(pre1+'_'+prr[i]).value = document.getElementById(pre2+'_'+srr[i]).innerHTML;
} else {
parent.document.getElementById(pre1+'_'+prr[i]).value = document.getElementById(pre2+'_'+srr[i]).innerHTML;
}
}
if (m == '2') {
parent.document.getElementById("popup").style.display = "none";
}
}
</script>
|