i have following code appends value 1 multiple field , remove value 1 multiple field javascript.
<html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $().ready(function() { $('#add').click(function() { return !$('#select1 option:selected').remove().appendto('#select2'); }); $('#remove').click(function() { return !$('#select2 option:selected').remove(); }); }); </script> </head> <body> <select multiple id="select1"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> <option value="4">option 4</option> </select> <a href="#" id="add">add >></a><br><br> <select multiple id="select2"></select> <a href="#" id="remove"><< remove</a> </body> </html> i replace first multiple field input field.
how do that?
i found solution:
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $().ready(function() { $('#add').click(function() { var option = new option($('#cellnbr').val(), "value"); $('#select2').append(option); }); $('#remove').click(function() { $('#select2 option:selected').remove(); }); }); </script> </head> <body> <input type="text" id="cellnbr"> <a href="#" id="add">add >></a><br><br> <select multiple id="select2"></select> <a href="#" id="remove"><< remove</a> </body> </html>
Comments
Post a Comment