NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<!DOCTYPE html>
<html>
<head>
<meta charset ="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width">
<title>Employee Details</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1 style="margin-bottom: 60px;">Employee Details :-</h1>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body style=" background-color: darkgrey;">

<select id="emp" name="hello" style="margin-left: auto;height: 30px;"></select><br>
<button onclick="getOption()" style="height: 30px; margin-left: auto ;margin-top: 20px;" > GET </button>
<p style="margin-left: auto;"> You selected :
<span class="output" style="font-weight: bold; text-decoration: underline;"></span>
</p>

<div class="slider" style="float: right;">
<input id="btnHide" type="button" value=">" >
</div>
<table id="xyz" style="width:auto; border: 2px solid black; background-color: cornflowerblue ; margin-top: 20px;margin-bottom: 10px; font-family: Arial, Helvetica, sans-serif;">
<tr >
<th data-column="name" data-order="desc" style=" text-align: center;padding: 15px;">Employee Name &#9650</th>
<th data-column="age"data-order="desc" style="border-left: 2px solid #333333; text-align: center;">Employee Age &#9650</th>
<th data-column="id" data-order="desc" style="border-left: 2px solid #333333; text-align: center;">Employee ID &#9650</th>
<th class="one" id="xyz" style="border-left: 2px solid #333333; text-align: center;">Employee Email</th>
</tr>
<tbody id="table" style="background-color:darkkhaki; " > </tbody>
</table>

<script>
var employee=[

{name :"Stefan Salvatore", age :"25", id : "123456", email:"[email protected]"},
{name :"Damon Salvatore", age :"28", id : "123457", email:"[email protected]"},
{name :"Elena Gilbert" , age :"22", id : "123458",email:"[email protected]"},
{name :"Caroline Forbes", age :"23", id : "123459",email:"[email protected]"},
{name :"Bonnie Benett" , age :"22", id : "123460",email:"[email protected]"},
{name :"Niklaus Mikaelson", age :"35", id : "123461",email:"[email protected]"},
{name :"Elijah Mikaelson", age :"40", id : "123462",email:"[email protected]"},
{name :"Rebekah Mikaelson", age :"32", id : "123463",email:"[email protected]"},
{name :"Finn Mikaelson", age :"36", id : "123464",email:"[email protected]"},
{name :"Kol Mikaelson", age :"30", id : "123465",email:"[email protected]"},

];

$('th').on('click' , function(){
var column = $(this).data('column');
var order = $(this).data('order');
var text =$(this).html();
text = text.substring(0 , text.length-1);
if(order == 'desc')
{
$(this).data('order' , 'asc');
employee = employee.sort((a,b)=> a[column]>b[column] ? 1 : -1);
text += '&#9660' ;
}
else
{
$(this).data('order' , 'desc');
employee = employee.sort((a,b)=> a[column] < b[column] ? 1 : -1);
text += '&#9650' ;
}
$(this).html(text)
buildTable(employee)
})

let l=employee.length;
let select=document.getElementById("emp");
for( let i=0;i<l;i++)
{
var opt = document.createElement('option');
opt.innerHTML = employee[i].name;
select.appendChild(opt);
}
buildTable(employee)
function buildTable(data){
var Table = document.getElementById('table');
Table.innerHTML ='';
for (var j=0;j<data.length;j++){
var row = `<tr onMouseOver="this.style.color='cornsilk'" onMouseOut="this.style.color='black'" >
<td style=" text-align: center;height: 20px;">${data[j].name}</td>
<td style="border-left: 2px solid #333333; text-align: center;height: 20px;">${data[j].age}</td>
<td style="border-left: 2px solid #333333; text-align: center;height: 20px;">${data[j].id}</td>
<td class="one" style="border-left: 2px solid #333333; text-align: center;height: 20px;">${data[j].email}</td>
</tr>`
Table.innerHTML += row;
}

}
function getOption() {
selectElement = document.querySelector('#emp');
output = selectElement.value;
document.querySelector('.output').textContent = output;
var Table = document.getElementById('table');
for (var k=0;k<employee.length;k++)
{
if(output === employee[k].name){
var row = `<tr style="width: auto;margin-left: 150px;margin-bottom: 10px; font-family: Arial, Helvetica, sans-serif;">
<td style=" text-align: center;height: 20px;">${employee[k].name}</td>
<td style="border-left: 2px solid #333333; text-align: center;height: 20px;">${employee[k].age}</td>
<td style="border-left: 2px solid #333333; text-align: center;height: 20px;">${employee[k].id}</td>
<td class="one" style="border-left: 2px solid #333333; text-align: center;height: 20px;">${employee[k].email}</td>
</tr>`
Table.innerHTML = row;
}

}
}
$(document).ready(function() {
$('#btnHide').click(function() {

$('#xyz th:nth-child(4)').toggle();
$('#xyz td:nth-child(4)').toggle();
});
});


</script>

<style>

.slider{
display: none;
}
@media only screen and (max-width: 480px)
{
.one
{
display: none;
}

.slider{
display: flex;
}

.slide{
display: block;
box-sizing: border-box;
height: fit-content;
}
.hidden
{
display: none;
}

}
</style>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.