Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
var myArray = [
{'name':'Solo trip', 'stay':'2nights and 3 days', 'destination':'Munnar,Kottayam,Kochi','price':'10,500'},
{'name':'Couple package', 'stay':'2nights and 3 days', 'destination':'Munnar,Kottayam,Kochi','price':'21,000'},
{'name':'Small Family', 'stay':'2nights and 3 days', 'destination':'Munnar,Kottayam,Kochi','price':'40,000'},
{'name':'Large Family or Group', 'stay':'2nights and 3 days', 'destination':'Munnar,Kottayam,Kochi','price':'80,000'},
{'name':'Solo trip', 'stay':'2nights and 3 days', 'destination':'Cochin,Alleppey,Trivandrum','price':'11,500'},
{'name':'Couple package', 'stay':'2nights and 3 days', 'destination':'Cochin,Alleppey,Trivandrum','price':'25,000'},
{'name':'Small Family', 'stay':'2nights and 3 days', 'destination':'Cochin,Alleppey,Trivandrum','price':'43,000'},
{'name':'Large Family or Group', 'stay':'2nights and 3 days', 'destination':'Cochin,Alleppey,Trivandrum','price':'82,000'},
{'name':'Solo trip', 'stay':'2nights and 3 days', 'destination':'Kozhikode,Varkala,Munnar','price':'12,500'},
{'name':'Couple package', 'stay':'2nights and 3 days', 'destination':'Kozhikode,Varkala,Munnar','price':'28,000'},
{'name':'Small Family', 'stay':'2nights and 3 days', 'destination':'Kozhikode,Varkala,Munnar','price':'48,000'},
{'name':'Large Family or Group', 'stay':'2nights and 3 days', 'destination':'Kozhikode,Varkala,Munnar','price':'88,000'},
{'name':'Solo trip', 'stay':'2nights and 3 days', 'destination':'Munnar,Trivandrum,Kottayam','price':'13,500'},
{'name':'Couple package', 'stay':'2nights and 3 days', 'destination':'Munnar,Trivandrum,Kottayam','price':'26,000'},
{'name':'Small Family', 'stay':'2nights and 3 days', 'destination':'Munnar,Trivandrum,Kottayam','price':'49,000'},
{'name':'Large Family or Group', 'stay':'2nights and 3 days', 'destination':'Munnar,Trivandrum,Kottayam','price':'90,000'},
]
//Initial Table construction
function buildTable(data){
var table = document.getElementById('myTable')
table.innerHTML = '' // clear out the iterating data
for (var i = 0; i < data.length-12; i++){
var row = `<tr>
<td>${data[i].name}</td>
<td>${data[i].stay}</td>
<td>${data[i].destination}</td>
<td>${'Rs'} ${data[i].price}</td>
</tr>`
table.innerHTML += row
}
}
buildTable(myArray)
//Table Sorting logic
$('th').on('click', function(){
var column = $(this).data('column')
var order = $(this).data('order')
console.log('column clicked',column,order)
var text = $(this).html()
text = text.substring(0, text.length - 1)
console.log(text)
if(order == 'desc'){
$(this).data('order', "asc")
myArray = myArray.sort((a,b) => a[column] > b[column] ? 1 : -1)
text += '▼'
}else{
$(this).data('order', "desc")
myArray = myArray.sort((a,b) => a[column] < b[column] ? 1 : -1)
text += '▲'
}
$(this).html(text)
buildTable(myArray)
})
// Table Pagination Logic
var current_page = 1;
var records_per_page = entries;
// function userinput(){
// var entries = document.getElementById("entry").value;
// }
// For Previous Button
function prevPage()
{
if (current_page > 1) {
current_page--;
changePage(current_page);
}
}
//For Next Button
function nextPage()
{
if (current_page < numPages()) {
current_page++;
changePage(current_page);
}
}
//For changing page
function changePage(page)
{
var btn_next = document.getElementById("btn_next");
var btn_prev = document.getElementById("btn_prev");
var listing_table = document.getElementById("myTable");
var page_span = document.getElementById("page");
// Validating page
if (page < 1)
page = 1;
if (page > numPages())
page = numPages();
listing_table.innerHTML = "";
for (var i = (page-1) * records_per_page; i < (page * records_per_page); i++) {
var row = `<tr>
<td>${myArray[i].name}</td>
<td>${myArray[i].stay}</td>
<td>${myArray[i].destination}</td>
<td>${'Rs'} ${myArray[i].price}</td>
</tr>`
listing_table.innerHTML += row;
}
page_span.innerHTML = page;
if (page == 1) {
btn_prev.disabled = true;
} else {
btn_prev.disabled = false;
}
if (page == numPages()) {
btn_next.disabled = true;
} else {
btn_next.disabled = false;
}
}
//Logic for number of pages
function numPages()
{
return Math.ceil(myArray.length / records_per_page);
}
window.onload = function() {
changePage(1);
};
![]() |
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