$(document).ready(function() {
$('#somebutton').click(function() {
$.get('List', function(responseJson) {
$.each(responseJson, function(index, item) {
var elem=$('<input type="checkbox" id="item" value='+item+'/> ' + item + '<br />');
$('#somediv').append('<input type="checkbox" id="item" value='+item+'/> ' + item + '<br />');
});
$('#somediv').append('<button id="newButton">'+"retrieve"+'</button> <br />');
});
});
$("#newButton").click(function(){
var data = { 'checkBoxList[]' : []};
var list=$(":input:item:checked");
$(list.each(function() {
data['checkBoxList[]'].push($(this).val());
}));
$.get("Data",data,function(responseText){
$('#somediv').text(responseText);
});
});
});
(i’m new to jQuery)
What i’m trying to do is
call a servlet ,which then gives me some list of checkboxes
select the required ones and then again submit to another servlet
which takes inputs from checkboxes
to display the info based on selection.
getting list of checkboxes from servlet is working fine, which creates dynamically a button also
when i clicked the button, it doesn’t do anything , i donno why
For one thing I could use a
classbecause with your current implementation you could end up with multiple buttons with the same id.So what you can do is:
Also I am not sure what you are doing here:
Just do: