el var dump no me los muestra
solo me muestra el del select 1 cuando no paso nada
javascript
Código PHP:
<script type="text/javascript">
jQuery(document).ready(function(){
// Dual Box Select
var db = jQuery('#dualselect').find('.ds_arrow button'); //get arrows of dual select
var sel1 = jQuery('#dualselect select:first-child'); //get first select element
var sel2 = jQuery('#dualselect select:last-child'); //get second select element
sel2.empty(); //empty it first from dom.
db.click(function(){
var t = (jQuery(this).hasClass('ds_prev'))? 0 : 1; // 0 if arrow prev otherwise arrow next
if(t) {
sel1.find('option').each(function(){
if(jQuery(this).is(':selected')) {
jQuery(this).attr('selected',false);
var op = sel2.find('option:first-child');
sel2.append(jQuery(this));
}
});
} else {
sel2.find('option').each(function(){
if(jQuery(this).is(':selected')) {
jQuery(this).attr('selected',false);
sel1.append(jQuery(this));
}
});
}
return false;
}) });
$('#form1').submit(function() {
var sel2 = $('#dualselect select:last-child');
sel2.find('option').each(function(){
var hidden = $('<input type="hidden" name="selectedOptions[]"/>');
hidden.val($(this).val());
sel2.after(hidden);
});
});
</script>
formulario
Código PHP:
<p>
<label>Dual Select</label>
<span id="dualselect" class="dualselect">
<select class="uniformselect" name="select1[]" multiple="multiple" size="10">
<?php
do {
?>
<option value="<?php echo $row_emp['id'];?>"<?php if (!(strcmp($row_emp['nombrecompleto'], $row_emp['nombrecompleto']))) {echo "SELECTED";} ?>><?php echo $row_emp['nombrecompleto']?></option>
<?php
} while ($row_emp = mysql_fetch_assoc($emp));
$rows = mysql_num_rows($emp);
if($rows > 0) {
mysql_data_seek($emp, 0);
$row_emp = mysql_fetch_assoc($emp);
}
?>
</select>
<span class="ds_arrow">
<button class="btn ds_prev"><i class="icon-chevron-left"></i></button><br />
<button class="btn ds_next"><i class="icon-chevron-right"></i></button>
</span>
<select name="select2[]" multiple="multiple" size="10">
<option value=""></option>
</select>
</span>
</p>