The img below describes what I am trying to do:
So when an entry from the select list is selected and button "Copy" is pressed, it will add an < li > element to the text area.
Any ideas, resources?
I give you an example, simple one:
HTML code:
<select multiple="multiple" class="options">
<option value="item1">Item 1</option>
<option value="item2">Item 2</option>
<option value="item3">Item 3</option>
<option value="item4">Item 4</option>
<option value="item5">Item 5</option>
</select>
<button id="test">Copy</button>
<textarea cols="25" rows="5" id="textarea"></textarea>
Javascript:
$(function(){
$("#test").on("click", function(){
$("#textarea").empty(); //to empty textarea content
$(".options option:selected").each(function(){
$("#textarea").append("* "+$(this).text()+ "\n");
});
});
});
Demo: http://jsfiddle.net/pf5CU/
Update
http://jsfiddle.net/pf5CU/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With