loop through each input and loop again and compare - javascript

As you can see from the below snippet, I first get the current parent row (".role_td_holder") of the currently click button and find divs that has a class of ".role_wrapper" within it and then put it on a variable named "this_roletr" and then I loop through each .flatRoundedCheckbox input, created a global variable named "role_name" and then loop through each divs that has a class of "role_wrapper" and then get each text and put it on the global variable "role_name" and then within the loop of ".flatRoundedCheckbox input" I compare if the current looped input's name attribute content is equal to the role_name content, if it does then put checked property to this currently looped input else if it doesn't then set the checked property to false. As below snippets, it works but only one checkbox is checked when theres actually two .role_wrapper or multiple that matched its text to any of the .flatRoundedCheckbox input name (e.g. if theres two divs that has a class of "role_wrapper, only one checkbox is checked when supposedly, two checkbox must be checked that matched its name attribute content to those divs that has a class of "role_wrapper" text. Any help, ideas, suggestion, recommendation, help is greatly appreciated. Thank you!
$(document).ready(function(){
$(document).on("click", ".trigger", function(){
var this_roletr = $(this).parents(".role_td_holder").find(".role_wrapper");
$("#checkbox_container .flatRoundedCheckbox input[type='checkbox']").each(function(){
var checkbox = $(this);
this_roletr.each(function(){
var role_name = $(this).text();
if(checkbox.attr("name") === role_name){
checkbox.prop("checked", true);
}else{
checkbox.prop("checked", false);
}
});
});
});
});
table, theader, th, tbody, tr, td, a, .extend{max-width: 100%;max-height: 100%;}
a:focus, a:active{outline: none;text-decoration: none;}
a, span, .cosbox_notify, .transation{-webkit-transition: all 200ms ease-in-out;-moz-transition: all 200ms ease-in-out;-ms-transition: all 200ms ease-in-out;-o-transition: all 200ms ease-in-out;transition: all 200ms ease-in-out;}
.bgwhite{background: #fff;}
.center{margin-left: auto;margin-right: auto;}
.clear{clear: both;float: none;}
.fade {transition: all 300ms linear 700ms;-webkit-transform: translate3d(0,0,0);-moz-transform: translate3d(0,0,0);-ms-transform: translate3d(0,0,0);-o-transform: translate3d(0,0,0);transform: translate3d(0,0,0);opacity: 1;}
.fade.out {opacity: 0;}
.table_scroll, .overflow_container{overflow: auto;}
.table_scroll_y{overflow-x: hidden; overflow-y: auto;}
.table_scroll_x{overflow-x: auto; overflow-y: hidden;}
.align_left{float: left;}
.align_right{float: right;}
.display_table{display: table;}
.display_block{display: block;}
.overflow_hidden{overflow: hidden;}
.overflow_auto{overflow: auto};
.overflow_x{overflow-x: auto};
.overflow_y{overflow-y: auto};
.inline_block{display: inline-block;}
.divider{height: 10px;}
.padding_2px{padding: 2px;}
.padding_3px{padding: 3px;}
.padding_4px{padding: 4px;}
.padding_5px{padding: 5px;}
.padding_6px{padding: 6px;}
.padding_7px{padding: 7px;}
.padding_8px{padding: 8px;}
.padding_9px{padding: 9px;}
.padding_10px{padding: 10px;}
.margin_left2px{margin-left: 2px;}
.margin_left3px{margin-left: 3px;}
.margin_left4px{margin-left: 4px;}
.margin_left5px{margin-left: 5px;}
.margin_left6px{margin-left: 6px;}
.margin_left7px{margin-left: 7px;}
.margin_left8px{margin-left: 8px;}
.margin_left9px{margin-left: 9px;}
.margin_left10px{margin-left: 10px;}
.margin_right2px{margin-right: 2px;}
.margin_right3px{margin-right: 3px;}
.margin_right4px{margin-right: 4px;}
.margin_right5px{margin-right: 5px;}
.margin_right6px{margin-right: 6px;}
.margin_right7px{margin-right: 7px;}
.margin_right8px{margin-right: 8px;}
.margin_right9px{margin-right: 9px;}
.margin_right10px{margin-right: 10px;}
.margin_top2px{margin-top: 2px;}
.margin_top3px{margin-top: 3px;}
.margin_top4px{margin-top: 4px;}
.margin_top5px{margin-top: 5px;}
.margin_top6px{margin-top: 6px;}
.margin_top7px{margin-top: 7px;}
.margin_top8px{margin-top: 8px;}
.margin_top9px{margin-top: 9px;}
.margin_top10px{margin-top: 10px;}
.margin_bottom2px{margin-bottom: 2px;}
.margin_bottom3px{margin-bottom: 3px;}
.margin_bottom4px{margin-bottom: 4px;}
.margin_bottom5px{margin-bottom: 5px;}
.margin_bottom6px{margin-bottom: 6px;}
.margin_bottom7px{margin-bottom: 7px;}
.margin_bottom8px{margin-bottom: 8px;}
.margin_bottom9px{margin-bottom: 9px;}
.margin_bottom10px{margin-bottom: 10px;}
.status_approve{color: #76b729 !important;}
.status_reject{color: #eb5959 !important;}
.status_pending{color: #ebca59 !important;}
.green_button{
margin: 0 auto;
display: block;
text-transform: uppercase;
font: normal 13px 'mpregular', sans-serif;
color: #fff;
padding: 7px 7px 3px 7px;
width: 85px;
color: #fff;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 3px solid #659d24;
background: #76b729;
text-align: center;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.green_button:hover{outline: none;color:#ffffff;background:#659d24 !important;border-bottom: 3px solid #659d24 !important;}
.green_button:focus, .green_button:active{outline: none;}
.flatRoundedCheckbox
{
width: 40px;
height: 21px;
position: relative;
}
.flatRoundedCheckbox div
{
width: 100%;
height:100%;
background: #d3d3d3;
border-radius: 50px;
position: relative;
}
.flatRoundedCheckbox label
{
display: block;
width: 16px;
height: 16px;
border-radius: 50px;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
cursor: pointer;
position: absolute;
top: 2px;
z-index: 1;
left: 3px;
background: #FFF;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0 2px 1px rgba(0,0,0,0.3);
box-shadow: 0 2px 1px rgba(0,0,0,0.3);
}
.flatRoundedCheckbox input[type="checkbox"]{
display: none;
}
.flatRoundedCheckbox input[type=checkbox]:checked ~ div
{
background: #4fbe79;
}
.flatRoundedCheckbox input[type=checkbox]:checked ~ label {
left: 22px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<thead><th>Full name</th><th>role</th><th>Option</th></thead>
<tbody>
<tr class="role_td_holder">
<td>Full name 1</td>
<td>
<div class="display_table center role_wrapper_container">
<button class="draggable extend role_wrapper">Role 1</button>
</div>
<div class="display_table center role_wrapper_container">
<button class="draggable extend role_wrapper">Role 2</button>
</div>
</td>
<td>
<button class="trigger">Click</button>
</td>
</tr>
<tr class="role_td_holder">
<td>Full name 1</td>
<td>
<div class="display_table center role_wrapper_container">
<button class="draggable extend role_wrapper">Role 1</button>
</div>
</td>
<td>
<button class="trigger">Click</button>
</td>
</tr>
<tr class="role_td_holder">
<td>Full name 1</td>
<td>
<div class="display_table center role_wrapper_container">
<button class="draggable extend role_wrapper">Role 1</button>
</div>
<div class="display_table center role_wrapper_container">
<button class="draggable extend role_wrapper">Role 2</button>
</div>
</td>
<td>
<button class="trigger">Click</button>
</td>
</tr>
</table>
<div class="extend clear padding_7px overflow_auto" id="checkbox_container">
<div class="display_table align_left margin_right3px margin_bottom3px">
<div class="display_block align_left margin_right3px checkbox_label" style="font-size: 13px;">Role 1</div>
<div class="flatRoundedCheckbox align_left">
<input type="checkbox" value="5" name="Role 1">
<label></label>
<div></div>
</div>
</div>
<div class="display_table align_left margin_right3px margin_bottom3px">
<div class="display_block align_left margin_right3px checkbox_label" style="font-size: 13px;">Role 2</div>
<div class="flatRoundedCheckbox align_left">
<input type="checkbox" value="6" name="Role 2">
<label></label>
<div></div>
</div>
</div>
<div class="display_table align_left margin_right3px margin_bottom3px">
<div class="display_block align_left margin_right3px checkbox_label" style="font-size: 13px;">Role 3</div>
<div class="flatRoundedCheckbox align_left">
<input type="checkbox" value="7" name="Role 3">
<label></label>
<div></div>
</div>
</div>
</div>

try this
$(this).parents(".role_td_holder").find(".role_wrapper").each(function(){
var role_name = $.trim($(this).text());
$("#checkbox_container .flatRoundedCheckbox input[type='checkbox']").each(function(){
if($(this).attr("name") === role_name){
$(this).prop("checked", true);
}
// alert("asdasd");
});
});

Related

Why does z-index not work in text, even though it is set?

So, I have this example of an html form:
function submit(){
document.getElementById('load').style.width = "80%";
}
.load{
border-radius:12px;
background-color:#00ff88;
height:80%;
position:relative;
z-index:2;
top:0;
display:block;
width:0;
transition: 1.5s ease-in;
margin:5% auto 15% auto;
position:fixed;
top:2.5%;
left:10%;
}
.load:hover{
border-radius: 8px;
}
body {font-family: Noto Sans, IBM Plex Sans Condensed; overflow:hidden;}
* {box-sizing: border-box;
/* Set a style for all buttons */
button {
border-radius: 12px;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
transition: 0.3s ease;
font-size: 15px;
font-weight: bold;
outline-style: solid;
outline-width:1px;
}
button:hover {
border-radius: 5px;
opacity:1;
}
/* Extra styles for the cancel button */
.cancelbtn {
padding: 14px 20px;
background-color: #f44336;
}
/* Float cancel and signup buttons and add an equal width */
.cancelbtn, .signupbtn, .refreshbtn {
float: left;
width: 100%;
}
/* Add padding to container elements */
.container {
padding: 16px;
border-radius: 12px;
box-shadow: 5px 5px 40px -1px rgba(10,10,10,0.74);
transition: .6s ease;
}
.container:hover {
box-shadow: 10px 10px 40px -3px rgba(10,10,10,0.74);
border-radius: 5px;
}
.clearfix > p{
position:fixed;
bottom:15%;
left:40%;
margin-top: 0%;
vertical-align: top;
}
#options{
overflow-y:scroll;
}
}
<div class="center load" id="load" style="position: absolute"></div>
<div class="container modal-content" style="height:80%;max-height:100%;position:fixed;top:2.5%;left:10%;z-index:1;" id="quiz">
<div id="content" style="z-index: 50;position:relative;background-color:rgba(255, 255, 255, 0)">
<h1 id="Qtitle">Example Poll [title]</h1>
<hr>
<div id="options" style="display: block;">
<p style="font-size:20px;" onclick="select('option1')"><input type="radio" name="cXVlc3Rpbwo" value="1" id="option1"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="first" onclick="select('option1')"><b>[Option1]</b></label></p>
<p style="font-size:20px;" onclick="select('option2')"><input type="radio" name="cXVlc3Rpbwo" value="2" id="option2"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="second" onclick="select('option2')"><b>[Option2]</b></label></p>
<p style="font-size:20px;" onclick="select('option3')"><input type="radio" name="cXVlc3Rpbwo" value="3" id="option3"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="third" onclick="select('option3')"><b>[Option3]</b></label></p>
<p style="font-size:20px;" onclick="select('option4')"><input type="radio" name="cXVlc3Rpbwo" value="4" id="option4"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="fourth" onclick="select('option4')"><b>[Option4]</b></label></p>
</div>
<input name="UUNvZGU" style="display:none;" id="QCode" value="error">
<br>
<hr>
<div class="clearfix" style="margin-bottom:50%;margin-top:0%;">
<button class="signupbtn" onclick="submit()" id="submit">Vote</button>
</div>
</div>
</div>
<script>
function submit(){
document.getElementById('load').style.width = "80%";
}
</script>
As you can see, even though the back div's z-index is 1, the green div's is 2 and the text's is 50, the green div grows over the text.
Any suggestions?
(Sorry for the terrible snippet quality, but, my project is 3000 lines long and I got a bit confused. Please run the snippet in full screen instead).
If you give the green div a z-index that is lower than the z-index of the form, then everything should work as you wanted.
I gave the green div a height and a width too see it. Then i gave it a z-index of 0 (Remove the heightand the width!!! I just added that to show)
Here's an image of what i added:
Here is how it looks like now:
Here's the code:
.load{
border-radius:12px;
background-color:#00ff88;
height:80%;
position:relative;
z-index:2;
top:0;
display:block;
width:0;
transition: 1.5s ease-in;
margin:5% auto 15% auto;
position:fixed;
top:2.5%;
left:10%;
/* I gave the green div a height and a width too see it */
height: 100px;
width: 100px;
/* z-index for the green Div */
z-index: 0;
}
.load:hover{
border-radius: 8px;
}
body {font-family: Noto Sans, IBM Plex Sans Condensed; overflow:hidden;}
* {box-sizing: border-box;
/* Set a style for all buttons */
button {
border-radius: 12px;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
transition: 0.3s ease;
font-size: 15px;
font-weight: bold;
outline-style: solid;
outline-width:1px;
}
button:hover {
border-radius: 5px;
opacity:1;
}
/* Extra styles for the cancel button */
.cancelbtn {
padding: 14px 20px;
background-color: #f44336;
}
/* Float cancel and signup buttons and add an equal width */
.cancelbtn, .signupbtn, .refreshbtn {
float: left;
width: 100%;
}
/* Add padding to container elements */
.container {
padding: 16px;
border-radius: 12px;
box-shadow: 5px 5px 40px -1px rgba(10,10,10,0.74);
transition: .6s ease;
}
.container:hover {
box-shadow: 10px 10px 40px -3px rgba(10,10,10,0.74);
border-radius: 5px;
}
.clearfix > p{
position:fixed;
bottom:15%;
left:40%;
margin-top: 0%;
vertical-align: top;
}
#options{
overflow-y:scroll;
}
}
<div class="center load" id="load" style="position: absolute"></div>
<div class="container modal-content" style="height:80%;max-height:100%;position:fixed;top:2.5%;left:10%;z-index:1;" id="quiz">
<div id="content" style="z-index: 50;position:relative;background-color:rgba(255, 255, 255, 0)">
<h1 id="Qtitle">Example Poll [title]</h1>
<hr>
<div id="options" style="display: block;">
<p style="font-size:20px;" onclick="select('option1')"><input type="radio" name="cXVlc3Rpbwo" value="1" id="option1"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="first" onclick="select('option1')"><b>[Option1]</b></label></p>
<p style="font-size:20px;" onclick="select('option2')"><input type="radio" name="cXVlc3Rpbwo" value="2" id="option2"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="second" onclick="select('option2')"><b>[Option2]</b></label></p>
<p style="font-size:20px;" onclick="select('option3')"><input type="radio" name="cXVlc3Rpbwo" value="3" id="option3"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="third" onclick="select('option3')"><b>[Option3]</b></label></p>
<p style="font-size:20px;" onclick="select('option4')"><input type="radio" name="cXVlc3Rpbwo" value="4" id="option4"><label style="cursor:pointer;" for="cXVlc3Rpbwo" id="fourth" onclick="select('option4')"><b>[Option4]</b></label></p>
</div>
<input name="UUNvZGU" style="display:none;" id="QCode" value="error">
<br>
<hr>
<div class="clearfix" style="margin-bottom:50%;margin-top:0%;">
<button class="signupbtn" onclick="submit()" id="submit">Vote</button>
</div>
</div>
</div>
<script>
function submit(){
document.getElementById('load').style.width = "80%";
}
</script>

How to create collapsible content with split button? (HTML/CSS/JS)

With two columns (left indicates name; right provide collapse function(a button)), how would you create collapsible content on the next row with full width (covers both columns)?
I am only able to collapse within a certain column. I tried to collapse a row below by creating a new div, but then the collapsing action no longer seems to work.
It should look like this:
Thank you for your help!
JavaScript is from: https://www.w3schools.com/howto/howto_js_collapsible.asp
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}
:root {
--colorbggray: rgb(65,65,65);
--colorlightgray: rgb(150,150,150);
--colorcyan: rgb(0, 229, 255);
--colorgreen: rgb(0, 255, 0);
--colorUpGrey: rgb(135,135,135);
--colorLowGrey: rgb(38,38,38);
--colorMidGrey: rgb(95,95,95);
--colorGreen: rgb(11,69,2);
--colorAmber: orange;
--colorRed: red;
}
.verticalmenu-auto {
display: flex;
align-items: stretch;
background-color: #f1f1f1;
}
.verticalmenu-auto > div {
border-top: 2px solid var(--colorUpGrey);
border-bottom: 2px solid var(--colorLowGrey);
border-left: 2px solid var(--colorUpGrey);
border-right: 2px solid var(--colorLowGrey);
background: var(--colorMidGrey); color: white;
width: 100px;
padding-top: 8px;
padding-bottom: 8px;
padding-right: 16px;
padding-left: 16px;
margin: 0.5px;
text-align: left;
font-size: 16px;
}
.verticalmenu-auto li, {
border-top: 2px solidauto var(--colorUpGrey);
border-bottom: 2px solid var(--colorLowGrey);
border-left: 2px solid var(--colorUpGrey);
border-right: 2px solid var(--colorLowGrey);
background: var(--colorMidGrey);
}
.collapsible {
background: var(--colorMidGrey); color: white;
cursor: pointer;
width: 100%;
border: none;
text-align: center;
outline: none;
}
.collapsible:after {
content: '\1433';
float: center;
transform: scale(.7, 1);
}
.active:after {
content: "\142F";
transform: scale(1, .7);
}
.content {
max-height: 0;
overflow: hidden;
transition: max-height 0.0s ease-out;
grid-column-start: -1;
grid-column-end: 1;
background-color: gray;
}
<body>
<p>On right side open content which is has the width of both columns combined</p>
<ul style="list-style:none;padding-left:0;">
<li>
<div class="verticalmenu-auto">
<div style="flex-grow: 10">Name</div>
<div style="flex-grow: 1; text-align: center">
<button class="collapsible"></button>
<div class='content'>
<p> content</p>
</div>
</div>
</div>
</li>
<li>
<div class="verticalmenu-auto">
<div style="flex-grow: 10">Name</div>
<div style="flex-grow: 1; text-align: center">
<button class="collapsible"></button>
<div class='content'>
<p> content</p>
</div>
</div>
</div>
</li>
A slight change in your JS toggle and also putting content outside the parent div so that it act as block
$(document).ready(function () {
$('.collapsible').on('click', function(event){
event.preventDefault();
// create accordion variables
var accordion = $(this);
var accordionContent = accordion.closest('.verticalmenu-auto').next('.content');
// toggle accordion link open class
accordion.toggleClass("active");
// toggle accordion content
accordionContent.slideToggle(250);
accordionContent.toggleClass("active");
});
});
:root {
--colorbggray: rgb(65,65,65);
--colorlightgray: rgb(150,150,150);
--colorcyan: rgb(0, 229, 255);
--colorgreen: rgb(0, 255, 0);
--colorUpGrey: rgb(135,135,135);
--colorLowGrey: rgb(38,38,38);
--colorMidGrey: rgb(95,95,95);
--colorGreen: rgb(11,69,2);
--colorAmber: orange;
--colorRed: red;
}
.verticalmenu-auto {
display: flex;
align-items: stretch;
background-color: #f1f1f1;
}
.verticalmenu-auto > div {
border-top: 2px solid var(--colorUpGrey);
border-bottom: 2px solid var(--colorLowGrey);
border-left: 2px solid var(--colorUpGrey);
border-right: 2px solid var(--colorLowGrey);
background: var(--colorMidGrey); color: white;
width: 100px;
padding-top: 8px;
padding-bottom: 8px;
padding-right: 16px;
padding-left: 16px;
margin: 0.5px;
text-align: left;
font-size: 16px;
}
.verticalmenu-auto li, {
border-top: 2px solidauto var(--colorUpGrey);
border-bottom: 2px solid var(--colorLowGrey);
border-left: 2px solid var(--colorUpGrey);
border-right: 2px solid var(--colorLowGrey);
background: var(--colorMidGrey);
}
.collapsible {
background: var(--colorMidGrey); color: white;
cursor: pointer;
width: 100%;
border: none;
text-align: center;
outline: none;
}
.collapsible:after {
content: '\1433';
float: center;
transform: scale(.7, 1);
}
.collapsible.active:after {
content: "\142F";
transform: scale(1, .7);
}
.content {
display: none;
overflow: hidden;
transition: max-height 0.0s ease-out;
grid-column-start: -1;
grid-column-end: 1;
background-color: #BFBFBF;
padding: 10px;
color: #fff;
}
.content.active {
height: auto;
display: block !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<p>On right side open content which is has the width of both columns combined</p>
<ul style="list-style:none;padding-left:0;">
<li>
<div class="verticalmenu-auto">
<div style="flex-grow: 10">Name</div>
<div style="flex-grow: 1; text-align: center">
<button class="collapsible"></button>
</div>
</div>
<div class='content'>
<p> content</p>
</div>
</li>
<li>
<div class="verticalmenu-auto">
<div style="flex-grow: 10">Name</div>
<div style="flex-grow: 1; text-align: center">
<button class="collapsible"></button>
</div>
</div>
<div class='content'>
<p> content</p>
</div>
</li>
Are you need like this?
var buttons = document.querySelectorAll('.toggle');
buttons.forEach(function(el) {
el.addEventListener('click', function(event) {
var target = event.target.getAttribute('target');
document.getElementById(target).classList.toggle('expanded');
});
});
table {
width: 100%;
}
table td:nth-child(2) {
width: 100px;
}
.row-detail {
display: none;
}
.expanded {
display: block;
}
<table>
<tr>
<td>Row 1</td>
<td><button class="toggle" target="row-detail-1">Toggle 1</button></td>
</tr>
<tr id="row-detail-1" class="row-detail">
<td colspan="2">This detail from row 1</td>
</tr>
<tr>
<td>Row 2</td>
<td><button class="toggle" target="row-detail-2">Toggle 2</button></td>
</tr>
<tr id="row-detail-2" class="row-detail">
<td colspan="2">This detail from row 2</td>
</tr>
<tr>
<td>Row 3</td>
<td><button class="toggle" target="row-detail-3">Toggle 3</button></td>
</tr>
<tr id="row-detail-3" class="row-detail">
<td colspan="2">This detail from row 3</td>
</tr>
</table>

Create a basic table with expanded row

I'm using Angular version 6 and want either an Angular solution or pure html/javascript solution for having a table with expanded rows.
So when you click a row it expands.
Note: I don't want to use angular material, jQuery or any third party.
This is my html table:
<table class="ex-table p3">
<thead class="ex-table__head">
<tr class="ex-table__row">
<th class="ex-table__cell">id</th>
<th class="ex-table__cell">First Name</th>
</tr>
</thead>
<tbody>
<tr class="ex-table__row" *ngFor="let item of data">
<td class="ex-table__cell">
{{item.od}}
</td>
<td class="ex-table__cell">
{{item.firstName}}
</td>
</tr>
</tbody>
</table>
I've attempted rowspan and colspan and nested tables but could'nt get that working.
Do you want something like below? . the rows can be expanded. even the whole table can be expanded at once.
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script type="text/javascript">
function toggle(btnID, eIDs) {
// Feed the list of ids as a selector
var theRows = document.querySelectorAll(eIDs);
// Get the button that triggered this
var theButton = document.getElementById(btnID);
// If the button is not expanded...
console.log(theButton.getAttribute("aria-expanded"))
if (theButton.getAttribute("aria-expanded") == "false") {
// Loop through the rows and show them
for (var i = 0; i < theRows.length; i++) {
theRows[i].classList.add("shown");
theRows[i].classList.remove("hidden");
}
// Now set the button to expanded
theButton.setAttribute("aria-expanded", "true");
// Otherwise button is not expanded...
} else {
// Loop through the rows and hide them
for (var i = 0; i < theRows.length; i++) {
theRows[i].classList.add("hidden");
theRows[i].classList.remove("shown");
}
// Now set the button to collapsed
theButton.setAttribute("aria-expanded", "false");
}
}
function toggle1(btnID, eIDs) {
// Feed the list of ids as a selector
var theRows = document.querySelectorAll(eIDs);
// Get the button that triggered this
var theButton = document.getElementById(btnID);
// If the button is not expanded...
if (theButton.getAttribute("aria-expanded") == "false") {
// Loop through the rows and show them
for (var i = 0; i < theRows.length; i++) {
theRows[i].classList.add("shown");
theRows[i].classList.remove("hidden");
}
// Now set the button to expanded
theButton.setAttribute("aria-expanded", "true");
document.getElementById("btnMSb1").setAttribute("aria-expanded", "true");
document.getElementById("btnMSb2").setAttribute("aria-expanded", "true");
document.getElementById("btnMSb3").setAttribute("aria-expanded", "true");
// Otherwise button is not expanded...
} else {
// Loop through the rows and hide them
for (var i = 0; i < theRows.length; i++) {
theRows[i].classList.add("hidden");
theRows[i].classList.remove("shown");
}
// Now set the button to collapsed
theButton.setAttribute("aria-expanded", "false");
document.getElementById("btnMSb1").setAttribute("aria-expanded", "false");
document.getElementById("btnMSb2").setAttribute("aria-expanded", "false");
document.getElementById("btnMSb3").setAttribute("aria-expanded", "false");
}
}
</script>
</head>
<style>
body {
font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.4;
background: #fefefe;
color: #333;
margin: 0 1em;
}
table {
width: 100%;
margin: 1em 0;
border-collapse: collapse;
}
caption {
text-align: left;
font-style: italic;
padding: 0.25em 0.5em 0.5em 0.5em;
}
th,
td {
padding: 0.25em 0.5em 0.25em 1em;
vertical-align: text-top;
text-align: left;
text-indent: -0.5em;
}
th {
vertical-align: bottom;
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
font-weight: bold;
}
.process {
margin-top: 35px;
display: inline-block;
width: 10%;
padding: 5px;
border-top: 3px solid black;
border-bottom: 3px solid black;
color: #fff;
font-style: normal;
font-weight: bold;
}
.row td:nth-of-type(2),
.cell td:nth-of-type(3) {
font-style: italic;
}
.row th:nth-of-type(3),
.row td:nth-of-type(3),
.cell th:nth-of-type(4),
.cell td:nth-of-type(4) {
text-align: right;
}
td[colspan] {
background-color: #f5f5f5;
color: #000;
font-weight: normal;
font-style: italic;
padding: 0;
text-indent: 0;
}
tr.shown,
tr.hidden {
display: table-row;
}
tr.hidden {
display: none;
}
.row button {
background-color: transparent;
border: .1em solid transparent;
font: inherit;
padding: 0.25em 0.5em 0.25em .25em;
width: 100%;
text-align: left;
}
.row button:focus,
.row button:hover {
background-color: #ddd;
outline: .2em solid #00f;
}
.row button svg {
width: .8em;
height: .8em;
margin: 0 0 -.05em 0;
fill: #66f;
transition: transform 0.25s ease-in;
transform-origin: center 45%;
}
.row button:hover svg,
.row button:focus svg {
fill: #00c;
}
/* Lean on programmatic state for styling */
.row button[aria-expanded="true"] svg {
transform: rotate(180deg);
}
.cell button {
font-size: 60%;
color: #000;
background-color: #00f;
padding: 0.3em 0.2em 0 0.2em;
border: 0.2em solid #00f;
border-radius: 50%;
line-height: 1;
text-align: center;
text-indent: 0;
transform: rotate(270deg);
}
.cell button svg {
width: 1.25em;
height: 1.25em;
fill: #fff;
transition: transform 0.25s ease-in;
transform-origin: center 45%;
}
.cell button:hover,
.cell button:focus {
background-color: #fff;
outline: none;
}
.cell button:hover svg,
.cell button:focus svg {
fill: #00f;
}
/* Lean on programmatic state for styling */
.cell button[aria-expanded="true"] svg {
transform: rotate(90deg);
}
/* Proven method to visually hide something but */
/* still make it available to assistive technology */
.visually-hidden {
position: absolute;
top: auto;
overflow: hidden;
clip: rect(1px 1px 1px 1px);
/* IE 6/7 */
clip: rect(1px, 1px, 1px, 1px);
width: 1px;
height: 1px;
white-space: nowrap;
}
</style>
<table class="cell">
<caption>Dashboard</caption>
<thead>
<tr>
<th><button type="button" id="btnMSb" aria-expanded="false" onclick="toggle1(this.id,'#MS01b,#MS02b,#MS03b');" aria-controls="MS01b MS02b MS03b" aria-label="3 more from" aria-labelledby="btnMSb lblMSb">
<svg xmlns="\http://www.w3.org/2000/svg"" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
</button></th>
<th>Batch</th>
<th>Status</th>
<th>Start</th>
<th>End</th>
<th>agreed</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button type="button" id="btnMSb1" aria-expanded="false" onclick="toggle(this.id,'#MS01b');" aria-controls="MS01b" aria-label="3 more from" aria-labelledby="btnMSb1 lblMSb1">
<svg xmlns="\http://www.w3.org/2000/svg"" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
</button>
</td>
<td>Batch1</td>
<td>Green</td>
<td>10AM</td>
<td>11AM</td>
<td>11:30AM</td>
</tr>
<tr id="MS01b" class="hidden">
<td></td>
<td colspan="5">
<div style="vertical-align: middle; text-align: center;height: 100px;">
<div class='process' style="border-right-style: none;border-left: 3px solid black; background-color: #16a085">Step1</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #F1A9A9">Step2</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #E4FFAE">Step3</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #BFC6B9">Step4</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #87FEF8">Step5</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right: 3px solid black;border-left-style: none; background-color: #FF9A9E">Step6</div>
</div>
</td>
</tr>
<tr>
<td>
<button type="button" id="btnMSb2" aria-expanded="false" onclick="toggle(this.id,'#MS02b');" aria-controls="MS02b" aria-label="3 more from" aria-labelledby="btnMSb2 lblMSb2">
<svg xmlns="\http://www.w3.org/2000/svg"" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
</button>
</td>
<td>Batch2</td>
<td>Green</td>
<td>2AM</td>
<td>4AM</td>
<td>5AM</td>
</tr>
<tr id="MS02b" class="hidden">
<td></td>
<td colspan="5">
<div style="vertical-align: middle; text-align: center;height: 100px;">
<div class='process' style="border-right-style: none;border-left: 3px solid black; background-color: #16a085">Step1</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #DB2929">Step2</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #C0FF3E">Step3</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #5A6351">Step4</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #01C5BB">Step5</div>
<div class='process' style="color:#222; margin-left:-5px ; border-right: 3px solid black;border-left-style: none; background-color: #FF9A9E">Step6</div>
</div>
</td>
</tr>
<tr>
<td>
<button type="button" id="btnMSb3" aria-expanded="false" onclick="toggle(this.id,'#MS03b');" aria-controls="MS03b" aria-label="3 more from" aria-labelledby="btnMSb3 lblMSb3">
<svg xmlns="\http://www.w3.org/2000/svg"" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
</button>
</td>
<td>Batch3</td>
<td>Amber</td>
<td>10AM</td>
<td>11AM</td>
<td>10:30AM</td>
</tr>
<tr id="MS03b" class="hidden">
<td></td>
<td colspan="5">
<div style="vertical-align: middle; text-align: center;height: 100px;">
<div class='process' style="border-right-style: none;border-left: 3px solid black; background-color: #1abc9c">Step1</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #3498db">Step2</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #34495e">Step3</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #2ecc71">Step4</div>
<div class='process' style="margin-left:-5px ; border-right-style: none;border-left-style: none; background-color: #9b59b6">Step5</div>
<div class='process' style="margin-left:-5px ; border-right: 3px solid black;border-left-style: none; background-color: #e74c3c">Step6</div>
</div>
</td>
</tr>
</tbody>
</table>
</html>

Right Align Drop Down Menu from an Icon in a Table Header

I would like to open a dropdown menu, aligned to the right under an icon, that appears in a span on a table header.
This is what I get:
It aligns naturally left under the icon, but I can't find a good way to align it to the right.
This is what I actually want:
Some suggestions advise using right:0; and position the filter container as absolute. This is not good in my case since I want the icon in the table header cell to be aligned to the right of the cell. Setting the container to absolute makes it difficult to align the icon in the table header.
I'm looking for a pure CSS solution if possible. The widths of the table cells and the widths of the dropdown menu are not fixed, so I cannot align things by specifying "pixels".
table {
font-family:Arial, Helvetica, sans-serif;
color:#666;
font-size:12px;
text-shadow: 1px 1px 0px #fff;
background:#eaebec;
margin:20px;
border:black 1px solid;
border-radius:3px;
border-collapse: collapse;
box-shadow: 0 1px 2px #d1d1d1;
}
table, th, td {
border: 1px solid black;
}
table th {
width:150px;
}
.context-icon {
float:right;
cursor:default;
color: green;
padding-right: 10px;
padding-left: 10px;
//position: absolute;
}
.filter {
visibility: hidden;
display: block;
position: absolute;
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 2px 6px;
max-height: 0px;
z-index: 1000;
height:auto;
transition: visibility 200ms, max-height 200ms ease-in-out;
//right:0;
}
.filter-open {
display: block;
max-height: 300px;
visibility: visible;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<body>
<table>
<thead>
<tr>
<th>first</th>
<th>
second
<span>
<i class="context-icon fa fa-lg fa-filter">
<select multiple class="filter filter-open">
<option >option1</option>
<option >option2</option>
<option >option3</option>
</select>
</i>
</span>
</th>
<th>third</th>
</tr>
</thead>
<tbody>
<tr>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
<tr>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
</tbody>
</table>
</body>
I have added position relative to i, and right 0px to the select :
i {
position: relative;
}
i select {
right: 0px;
}
table {
font-family:Arial, Helvetica, sans-serif;
color:#666;
font-size:12px;
text-shadow: 1px 1px 0px #fff;
background:#eaebec;
margin:20px;
border:black 1px solid;
border-radius:3px;
border-collapse: collapse;
box-shadow: 0 1px 2px #d1d1d1;
}
table, th, td {
border: 1px solid black;
}
table th {
width:150px;
}
.context-icon {
float:right;
cursor:default;
color: green;
padding-right: 10px;
padding-left: 10px;
//position: absolute;
}
.filter {
visibility: hidden;
display: block;
position: absolute;
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 2px 6px;
max-height: 0px;
z-index: 1000;
height:auto;
transition: visibility 200ms, max-height 200ms ease-in-out;
//right:0;
}
.filter-open {
display: block;
max-height: 300px;
visibility: visible;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<body>
<table>
<thead>
<tr>
<th>first</th>
<th>
second
<span>
<i class="context-icon fa fa-lg fa-filter">
<select multiple class="filter filter-open">
<option >option1</option>
<option >option2</option>
<option >option3</option>
</select>
</i>
</span>
</th>
<th>third</th>
</tr>
</thead>
</table>
</body>
Please add css below:
.filter {
right: 50%;
}

jquery image slider "Unslider" not working correctly

I got this snippet http://unslider.com/. I did everything asked there to get it working. But somehow it doesn't seem to load the next image in the queue and in return gives a blank space... You can see it here. easycounseling.org/new.html .. Here's the code:
<script>
$(function() {
$('.ss-area').unslider();
});
</script>
<div class="ss-area clearfix">
<ul class="img-sli">
<li class="fimg">
<div class="contents clearfix">
<div class="info-box">
<h2>DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo </h2>
<div class="con-us-btn-wr">
<button ONCLICK="window.location.href='contact.html'" class="con-us-mer-pg btn con-us">Contact us Now!</button>
</div>
<p>
to signup and avail of our limited period promotional offer!
</p>
</div>
</div>
<div class="mer-usp-wr">
<ul class="mer-usp clearfix" style="font-size:18px;">
<li>DEmo DEmo </li>
<li>DEmo DEmo DEmo </li>
<li>DEmo e</li>
<li>DEmo DEmo </li>
<li>DEmo DEmo </li>
</ul>
</div>
</li>
<li class="simg">
<div class="contents clearfix">
<div class="info-box">
<h2>DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo DEmo </h2>
<div class="con-us-btn-wr">
<button ONCLICK="window.location.href='contact.html'" class="con-us-mer-pg btn con-us">Contact us Now!</button>
</div>
<p>
to signup and avail of our limited period promotional offer!
</p>
</div>
</div>
<div class="mer-usp-wr">
<ul class="mer-usp clearfix" style="font-size:18px;">
<li>DEmo DEmo </li>
<li>DEmo DEmo DEmo </li>
<li>DEmo e</li>
<li>DEmo DEmo </li>
<li>DEmo DEmo </li>
</ul>
</div>
</li>
</ul>
</div>
The plugin is based on jQuery library
So you need to include jQuery and the plugin script file to make it work. The order in which they are loaded is important
---> jQuery
---> unslider plugin
Put this in the section where you have included the other script files. You can always test this by inspecting the console in Developer tools of the browser. It clearly shows the error.
Hi check this my unslider.com help file:
<!-- The HTML -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Unslider.com example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script src="http://unslider.com/unslider.min.js"type="text/javascript"></script>
<!-- JavaScript -->
<script type="text/javascript">
$(function() {
$('.banner').unslider({
speed: 500, // The speed to animate each slide (in milliseconds)
delay: 3000, // The delay between slide animations (in milliseconds)
complete: function() {}, // A function that gets called after every slide animation
keys: true, // Enable keyboard (left, right) arrow shortcuts
dots: true, // Display dot navigation
fluid: false // Support responsive design. May break non-responsive designs
});
var unslider = $('.banner').unslider();
$('.prev').click(function() {
unslider.data('unslider').prev();
});
$('.next').click(function() {
unslider.data('unslider').next();
});
return false;
});
</script>
<!-- CSS -->
<style type="text/css">
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
}
.banner {
position: relative;
width: 100%;
overflow: auto;
top: 50px;
/*z-index: -1;*/
font-size: 18px;
line-height: 24px;
text-align: center;
color: #FFFFFF;
text-shadow: 0 0 1px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.3);
background: #FFFFFF;
box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.banner ul {
list-style: none;
width: 300%;
}
.banner ul li {
display: block;
float: left;
min-height: 500px;
-o-background-size: 100% 100%;
-ms-background-size: 100% 100%;
-moz-background-size: 100% 100%;
-webkit-background-size: 100% 100%;
background-size: 100% 100%;
box-shadow: inset 0 -3px 6px rgba(0,0,0,.1);
}
.banner .inner {
padding: 360px 0 110px;
float: left;
vertical-align:-100px;
}
.banner h1, .banner h2 {
font-size: 40px;
line-height: 52px;
color: #fff;
}
.banner .btn {
display: inline-block;
margin: 25px 0 0;
padding: 9px 22px 7px;
clear: both;
color: #fff;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
text-decoration: none;
border : rgba(255, 255, 255, 0.4) solid 2px;
border-radius: 5px;
}
.banner .btn:hover {
background : rgba(255, 255, 255, 0.05);
}
.banner .btn:active {
-webkit-filter: drop-shadow(0 -1px 2px rgba(0,0,0,.5));
-moz-filter: drop-shadow(0 -1px 2px rgba(0,0,0,.5));
-ms-filter: drop-shadow(0 -1px 2px rgba(0,0,0,.5));
-o-filter: drop-shadow(0 -1px 2px rgba(0,0,0,.5));
filter: drop-shadow(0 -1px 2px rgba(0,0,0,.5));
}
.banner .btn, .banner .dot {
-webkit-filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
-moz-filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
-ms-filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
-o-filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}
.banner .dots {
position: absolute;
left: 0;
right: 0;
bottom: 20px;
width: 100%;
}
.banner .dots li {
display: inline-block;
width: 10px;
height: 10px;
line-height: 10px;
margin: 0 4px;
text-indent: -999em;
border: 2px solid #fff;
border-radius: 6px;
cursor: pointer;
opacity: .4;
-webkit-transition: background .5s, opacity .5s;
-moz-transition: background .5s, opacity .5s;
transition: background .5s, opacity .5s;
}
.banner .dots li.active {
background: #fff;
opacity: 1;
}
.unslider-arrow {
font-family: Expressway;
font-size: 50px;
text-decoration: none;
color: #3d3d3d;
background: rgba(255,255,255,0.7);
padding: 0 20px 5px 20px;
}
.next {
position: absolute;
top: 65%;
right: 0
}
.prev {
position: absolute;
top: 65%;
right: 90 /* change to left:0; if u wanna have arrow on left side */
}
</style>
</head>
<!-- Body of HTML document -->
<body>
<div class="slider">
<div class="banner">
<ul>
<li style="background-image: url('http://lorempixel.com/1200/600/');">
<div class="inner">
<h1>Some h1 text</h1>
<p>smaller p text</p>
<a class="btn" href="http://www.yourlink.com">Hyperlink</a>
</div>
</li>
<li style="background-image: url('http://lorempixel.com/1200/600/');">
<div class="inner">
<h1>Some h1 text</h1>
<p>smaller p text</p>
<a class="btn" href="http://www.yourlink.com">Hyperlink</a>
</div>
</li>
<li style="background-image: url('http://lorempixel.com/1200/600/');">
<div class="inner">
<h1>Some h1 text</h1>
<p>smaller p text</p>
<a class="btn" href="http://www.yourlink.com">Hyperlink</a>
</div>
</li>
<li style="background-image: url('http://lorempixel.com/1200/600/');">
<div class="inner">
<h1>Some h1 text</h1>
<p>smaller p text</p>
<a class="btn" href="http://www.yourlink.com">Hyperlink</a>
</div>
</li>
</ul>
</div>
←
→
</div>
</body>
</html>

Categories