<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<button id="get_all">Get All</button>
<table id="example" class="display nowrap" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="getvalue" name="id" value="1"/>Tiger Nixon</td>
<td>
<select name="optpos" id="optpos" class="form-control input-sm">
<option value="x">Position</option>
<option value="b">Director</option>
<option value="c">Technical Author</option>
<option value="d">Javascript Developer</option>
</select>
</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
<tr>
<td><input type="checkbox" class="getvalue" name="id" value="2"/>Garrett Winters</td>
<td>
<select name="optpos" id="optpos" class="form-control input-sm">
<option value="x">Position</option>
<option value="b">Director</option>
<option value="c">Technical Author</option>
<option value="d">Javascript Developer</option>
</select>
</td>
<td>Edinburgh</td>
<td>63</td>
<td>2011/07/25</td>
<td>$5,300</td>
</tr>
<tr>
<td><input type="checkbox" class="getvalue" name="id" value="3"/>Ashton Cox</td>
<td>
<select name="optpos" id="optpos" class="form-control input-sm">
<option value="x">Position</option>
<option value="b">Director</option>
<option value="c">Technical Author</option>
<option value="d">Javascript Developer</option>
</select>
</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$4,800</td>
</tr>
<tr>
<td><input type="checkbox" class="getvalue" name="id" value="4"/>Cedric Kelly</td>
<td>
<select name="optpos" id="optpos" class="form-control input-sm">
<option value="x">Position</option>
<option value="b">Director</option>
<option value="c">Technical Author</option>
<option value="d">Javascript Developer</option>
</select>
</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$3,600</td>
</tr>
<tr>
<td><input type="checkbox" class="getvalue" name="id" value="5"/>Jenna Elliott</td>
<td>
<select name="optpos" id="optpos" class="form-control input-sm">
<option value="x">Position</option>
<option value="b">Director</option>
<option value="c">Technical Author</option>
<option value="d">Javascript Developer</option>
</select>
</td>
<td>Edinburgh</td>
<td>33</td>
<td>2008/11/28</td>
<td>$5,300</td>
</tr>
</tbody>
</table>
</div>
<button id="ok" title="Save">Get it !!</button>
</body>
</html>
body {
font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #333;
background-color: #fff;
}
var table = new DataTable('#example');
$('#get_all').on('click', function () {
var checkboxes = [];
var select = [];
table
.column(0)
.nodes()
.to$()
.find('input[type="checkbox"]')
.each(function(value, idx){
checkboxes.push( $(this).is(':checked') );
});
table
.column(1)
.nodes()
.to$()
.find('select')
.each(function(value, idx){
select.push( $(this).val() );
});
console.log(checkboxes)
console.log(select)
});
table.rows().every(function(){
var Row=this.data();//store every row data in a variable
//var id = this.id();
// console.log(Row[2]);//show Row + Cell index
//console.log('Data in id: index: ' + index + ' is: ' + Row);
});
$(document).on('click', '.getit', function(){
var values = $('#table tbody').closest('tr').find('option:selected, input[type="checkbox"]:checked').map(function() {
return this.value;
}).get();
console.log( values );
var allcheck = [];
table.$('input[type="checkbox"]:checked').each(function(value, idx){
if($(this).val().substr(1,1)=='x'){
console.log($(this).val());
}
allcheck.push( $(this).val());
});
console.log( allcheck );
});
$('#example tbody').on('change', 'input[type="checkbox"]:enabled', function(){
// If checkbox is not checked
if(!this.checked){
console.log('A');
//$(this).closest('tr').find('select').prop('disabled', true);
//$('select', rows).prop('disabled', true);
//$(this).closest('tr').
//$(this).closest('tr').add($('#optpos').closest('tr')).addattr('disabled', true);
//$selectall.prop('checked',false);
$(this).closest('tr').find('select').prop('disabled', true);
}
else {
console.log('B');
$(this).closest('tr').find('select').prop('disabled', false);
}
});
$('#example tbody').on('change', 'select', function(){
myid = $(this).closest('tr').find('input[type="checkbox"]').eq(0).val().trim().substring(0,1);
mylabel = $(this).closest('tr').find('td').eq(0).text().trim();
opt = $(this).val().trim();
mydata = '<input type="checkbox" class="getvalue" name="myid" id="myid" value="'+myid+opt+'" checked/>'+mylabel+'sukses'+'</td>';
table.cell( $(this).closest('tr'), 0 ).data(mydata);
//<input type="checkbox" class="getvalue" name="myid" id="myid" value="1"/>Tiger Nixon</td>
console.log( myid+opt );
});
$("#ok").on("click", function(){
// Iterate over all checkboxes in the table
//var dataCheck;
//var form = this;
var allcheck = [];
table.$('input[type="checkbox"]:checked').each(function(value, idx){
allcheck.push( $(this).val() );
});
console.log(allcheck);
});
You can jump to the latest bin by adding /latest
to your URL
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + [ | Indents selected lines |
ctrl + ] | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Clone Bin |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |