Hi everyone,
I've found this followig javascript code that allows me to move listbox items to one another listbox.
The code works as he is on a submission form. But now I would like te reference my database listbox instead of the exemple.
Can someone help me?
Thanks
The name of my "from" listbox is ID_SEARCH_FORM and the "to" listbox is cbParamVirtual1.
CSS:
<style type="text/css">
select {
width: 200px;
float: left;
}
.controls {
width: 40px;
float: left;
margin: 10px;
}
.controls a {
background-color: #222222;
border-radius: 4px;
border: 2px solid #000;
color: #ffffff;
padding: 2px;
font-size: 14px;
text-decoration: none;
display: inline-block;
text-align: center;
margin: 5px;
width: 20px;
}
</style>
JAVASCRIPT:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>
<script>
function moveAll(from, to) {
$('#'+from+' option').remove().appendTo('#'+to);
}
function moveSelected(from, to) {
$('#'+from+' option:selected').remove().appendTo('#'+to);
}
function selectAll() {
$("select option").attr("selected","selected");
}
</script>
HTML:
<form name="selection" method="post" onSubmit="return selectAll()">
<select multiple size="10" id="from">
<option value="html">Html</option>
<option value="css">Css</option>
<option value="google">Google</option>
<option value="javascript">Javascript</option>
<option value="jquery">Jquery</option>
<option value="regex">Regex</option>
<option value="php">Php</option>
<option value="mysql">Mysql</option>
<option value="xml">Xml</option>
<option value="json">Json</option>
</select>
<div class="controls">
<a href="javascript:moveAll('from', 'to')">>></a>
<a href="javascript:moveSelected('from', 'to')">></a>
<a href="javascript:moveSelected('to', 'from')"><</a>
<a href="javascript:moveAll('to', 'from')" href="#"><<</a> </div>
<select multiple id="to" size="10" name="topics[]"></select>
<form>