i have two select box, now what i want is i want to move option from one select box to another via a button
Aşağıda benim kodudur:
php
<table>
<tr>
<td>
<select size="5" id="suppliedMovies" name="suppliedMovies">
<option selected="selected" value="">Select Movie</option>
<option value="1">sholay</option>
<option value="3">Jism</option>
<option value="4">Rog</option>
<option value="5">Zeher</option>
<option value="6">Awarpan</option>
<option value="7">Paap</option>
<option value="8">paanch<option>
<option value="9">no entry</option>
</select>
</td>
<td>
<input type="button" id="toRight" value=">>"><br>
<input type="button" id="toLeft" value="<<">
</td>
<td>
<select size="5" id="accquiredMovies" name="accquiredMovies">
<option> No item right now</option>
</select>
</td>
</tr>
</table>
Jquery
jQuery(document).ready( function() {
function displayVals() {
var myValues = jQuery("#suppliedMovies").val();
return myValues;
}
jQuery('#toRight').click(function(){
var x=displayVals();
console.log(x);
var txt=jQuery("#suppliedMovies option[value='"+x+"']").text();
console.log(txt);
if(x!=''){
jQuery('#accquiredMovies').append("<option value='"+x+"' >"+txt+"</option>");
}
});
});
im ki iyi çalışıyor, jQuery yukarıdaki kullanıyor ama, ben istiyorum
when one item is copy from one select box to another select box, then that item should be disable(or probably delete) from first select box (to prevent duplicate entry). i also want to move item from right to left select box please suggest me optimized jQuery . Thanks.
UPDATE
i her iki tarafta birden fazla seçme kutusunu kullanmak istiyorsanız? o zaman nasıl ben bu kullanabilirim?
more update
if i click on a item on rightselectbox and move it to left selectbox, and go further(post) then on right selectbox, there is nothing selected items?? what i need is on right selectbox, there all items shoud be always selected , otherwise what i need to do? after i move an item from right to left ,i again have to select rest of items on right selectbox and go further
solution for my update part
i aşağıdaki kodu kullanılan, bir göz atın ve birisi bu, herhangi bir hata / hata bulursa bana tavsiye lütfen. You teşekkür
jQuery('form').submit(function() {
jQuery('#accquiredMovies option').each(function(i) {
jQuery(this).attr("selected", "selected");
});
});