.


Divya


How To Display Select Data in a Table in jQuery


<!Doctype html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div class="content">
<div class="container-fluid">
<div class="col-md-6">
<div class="form-group col-xs-6">
<label class="control-label col-xs-6" for="Languages">Select Languages:</label>
<div class="col-xs-6" id="site">
<select class="form-control" name="sites" value="" id="sites" multiple="true">
<option value="java">java</option>
<option value="php">php</option>
<option value="jquery">jquery</option>
<option value="css">css</option>
<option value="wordpress">wordpress</option>
<option value="joomla">joomla</option>
</select>
</div>
</div>
<div class="form-group col-xs-6">
<div class="col-xs-6" id="site">
<button type="button" value="Get Values" id="submit1"class="btn btn-info btn-circle pull-right submit1"><i class="glyphicon glyphicon-plus"></i></button>
</div>
</div><br>
<div class="form-group col-xs-6">
<div class="col-xs-6">
<table class="table table-bordered" id="table1" border="2">
<thead class="thead-inverse">
<tr>
<th>Languages</th>
</tr>
</thead>
</table>
</div>
</div>
<script>
$("#submit1").click(function () {
{
var selected = $('.form-control :selected');
selected.each(function (a) {
$('#table1').append('<tr><td>'+$(this).val()+'</td></tr>');
});
}
});
</script>
</div>
</div>
</body>
</html>

Run it yourself

Demo


Languages

Download Source Code


.