Стоит задача передавать содержимое одного селекта в другой например как в этом коде
| Код | <html> <head> <title>Multy Select</title>
<script type="text/javascript"> function replacer(select1, select2, bool) { var element; if(bool) { while(element = select1.firstChild) select2.appendChild(select1.removeChild(element)); } else { for(var i = 0; element = select1.options[i]; i++) { if(element.selected) { select2.appendChild(element); element.selected = bool; } } } }
function mover(o, bool) { var e = o.options, i = o.selectedIndex, n = (bool) ? i - 1 : i + 1; (i > -1 && n >= 0 && n < o.length) ? (o.insertBefore(o.removeChild(e[i]), e[n]), o.selectedIndex = n) : ''; }
</script>
</head>
<body> <div> <form mathod="POST" action="http://localhost:8066/index3" name="TForm1_select" onsubmit="javasript:alert('form post')">
<table border="0"><tr><td>
<select name="select_left" multiple="multiple" size="10" id="select_left_id" ondblclick="javascript:replacer(document.getElementById('select_left_id'), document.getElementById('select_right_id'), false);"> <option value="1">№ 1</option> <option value="2">№ 2</option> <option value="3">№ 3</option> <option value="4">№ 4</option> <option value="5">№ 5</option> <option value="6">№ 6</option> <option value="7">№ 7</option> <option value="8">№ 8</option> <option value="9">№ 9</option> <option value="10">№ 10</option> </select> </td> <td> <button name="button_to_right" id="id_button_to_right" onclick="javascript:replacer(document.getElementById('select_left_id'), document.getElementById('select_right_id'), false); return false;" style="display:block; margin-bottom:15px"> > </button> <button name="button_all_to_right" id="id_button_all_to_right" onclick="javascript: replacer(document.getElementById('select_left_id'), document.getElementById('select_right_id'), true); return false;" style="display:block; margin-bottom:15px"> All>> </button>
<button name="button_all_to_left" id="id_button_all_to_left" onclick="javascript: replacer(document.getElementById('select_right_id'), document.getElementById('select_left_id'), true); return false;" style="display:block; margin-bottom:15px"> << All </button> <button name="button_to_left" id="id_button_to_left" onclick="javascript: replacer (document.getElementById('select_right_id'), document.getElementById('select_left_id'), false); return false;" style="display:block; margin-bottom:15px"> < </button>
</td> <td> <select name="select_right" multiple="multiple" size="10" id="select_right_id" ondblclick="javascript: replacer(document.getElementById('select_right_id'), document.getElementById('select_left_id'), false);"> </select> </td> <td> <img src="arrow_up.gif" onclick="javascript:mover(document.getElementById('select_right_id'), true)" style="display:block; margin-bottom:15px"/> <img src="arrow_down.gif" onclick="javascript:mover(document.getElementById('select_right_id'), false)" style="display:block; margin-bottom:15px"/> </td> </tr></table>
<input type="submit" value="send"/>
</form> </div> </body> </html>
|
только есть проблема, когда в левом селекте выделяешь строки или Ctrl'ом или Shift'ом то в правый селект передается максимум 2 значения как с этим можно побороться ?? |