I have few gridviews with a checkbox. I want the selected items in the gridview to be populated in a seperate list. Please suggest me a javascript library which can be useful. Example as below : Please see the pic
A:
You can do this by using the cloneNode DOM method but it gets a lot easier using jQuery. Untested conceptual code:
<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input:checkbox").click(function() {
if($(this).is(':checked')) {
var $item = $("<li id=\"copy_" + $(this).attr("id") + "\">");
$item.text($(this).parent().text());
$("#selectedList").append($item);
}
else {
$("#copy_" + $(this).attr("id"), "#selectedList").remove();
}
});
});
</script>
And in your HTML:
<ul id="itemList">
<li><input type="checkbox" id="one" />one</li>
<li><input type="checkbox" id="two" />two</li>
</ul>
<ul id="selectedList"></ul>
HTH,
JS
John Schulze
2010-01-22 16:57:40
Thanks for the lead John..ll work on it
404ram
2010-01-23 09:42:43