89 | | var toId = name + "_to"; |
90 | | elem = document.getElementById(toId); |
91 | | var o = new Option(newRepr, newId); |
92 | | SelectBox.add_to_cache(toId, o); |
93 | | SelectBox.redisplay(toId); |
| 89 | var field_name = name.replace(/^id_/, ''); |
| 90 | var fields = document.getElementsByName(field_name); |
| 91 | if (fields.length && fields[0].nodeName == 'INPUT' && fields[0].type == 'checkbox' && fields[0].parentNode.nodeName == 'LABEL' && fields[0].parentNode.parentNode.nodeName == 'LI') { |
| 92 | // Support for CheckboxSelectMultiple widget |
| 93 | var ul = fields[0].parentNode.parentNode.parentNode; |
| 94 | var li = document.createElement('li'); |
| 95 | var label = document.createElement('label'); |
| 96 | var input = document.createElement('input'); |
| 97 | input.type = 'checkbox'; |
| 98 | input.defaultChecked = true; |
| 99 | input.value = newId; |
| 100 | input.name = field_name; |
| 101 | ul.appendChild(li); |
| 102 | li.appendChild(label); |
| 103 | label.appendChild(input); |
| 104 | label.innerHTML += ' ' + newRepr; |
| 105 | } |
| 106 | else { |
| 107 | var toId = name + "_to"; |
| 108 | elem = document.getElementById(toId); |
| 109 | var o = new Option(newRepr, newId); |
| 110 | SelectBox.add_to_cache(toId, o); |
| 111 | SelectBox.redisplay(toId); |
| 112 | } |