I need to display Date/Datetime field already stored on Database, based upon the tag value

I’m not good in English sorry for that. I try to convey my problem as much as i can.

I created edit page in PHP to edit already saved data. The edit page will display already saved data’s near each record there will be edit button after clicking the button model window will open to edit the saved data’s., Right on that i facing some challenge.

I need to display Date/Datetime field already stored on Database, based upon the course type already selected. (Eg: If the course type value was already selected as ==1 then automatically date field with value should display, If the value selected as ==2 then datetime field with value should display) Hereby i attached the code.,

    <select name="selectCourseType" id="editCourseType" required>
    <option value=""  required>Select Courses Type</option>
        <?php 
            $sqlEdit = mysqli_query($link,"SELECT * FROM courses_type ORDER BY ct_id DESC");
            $row = mysqli_num_rows($sqlEdit);
            while ($row = mysqli_fetch_array($sqlEdit)){
            $ctID = $row['ct_id'];
            $ctName = $row['ct_name'];
        ?>
    <option <?php if ($ctID==$ctType){ ?> selected="selected" <?php } ?>  value="<?php echo $ctID ?>" ><?php echo $ctName ?></option>
        <?php } ?>
</select>
                    
                
<div id="editDeadlineDtfrom" hidden>                           
    <input class="form-control" type="date" name="deadlinedatefrom" />                        
</div>

<div id="editDeadlineDtto" hidden>                           
     <input class="form-control" type="date" name="deadlinedateto" />                          
</div>

<div id="editDurationDtfrom" hidden>                          
    <input class="form-control" type="datetime-local" name="durationdatefrom" />                         
</div>

<div id="editDurationDtto" hidden>                  
    <input class="form-control" type="datetime-local" name="durationdateto" />                            
</div>


 <script>
    document.getElementById("editCourseType").addEventListener("change", function() {
        const isDeadline = this.value === "2"
        document.getElementById("editDeadlineDtfrom").hidden = !isDeadline
        document.getElementById("editDeadlineDtto").hidden = !isDeadline
    })
    document.getElementById("editCourseType").addEventListener("change", function() {
        const isDuration = this.value === "1"
        document.getElementById("editDurationDtfrom").hidden = !isDuration
        document.getElementById("editDurationDtto").hidden = !isDuration
    })

</script>

I have a problem in Javscript where the images wont show up

So here is the code, I have checked by tes running it, I supposed the problem come from javascript,I already test one by one from html to css to javascript and I think there are some problems in javascript, also if anyone her know how to connect the selection with price it will be huge help.


<div id="app">
  <div class="main-wrapper">
    <h2>Desk Configurator</h2>
    <div class="img-main-wrapper">
      <transition name="fade" mode="out-in">
        <img v-if="currentChairIndex !== undefined" :key=chairs[currentChairIndex].main
             :src="chairs[currentChairIndex].main" class="img-absolute">
      </transition>
      <transition name="fade" mode="out-in">
        <img v-if="currentMatIndex !== undefined" :key=mats[currentMatIndex].main
             :src="mats[currentMatIndex].main" class="img-absolute">
      </transition>
      <img class="img-main" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/jarvis-silver-rec-base%5B1%5D.png" alt="">
    </div>
    <div v-if="progressBarOn" class="progress-bar-wrapper">
      <div class="progress-bar" :style="{width: progressBar}"></div>
    </div>
    <div class="content-row">
      <h3>Choose your chair</h3>
      <div class="img-thumbnail-wrapper">
        <img v-for="(chair, index) in chairs" 
             class="img-thumbnail" :src="chair.thumbnail" 
             @click="_handleImagePreview({key: 'currentChairIndex',value: index})"
             :class="currentChairIndex == index ? 'activeClass' : ''"
             >
        </img>
      </div>
    </div>
    <div class="content-row">
      <h3>Choose your mat</h3>
      <div class="img-thumbnail-wrapper">
        <img v-for="(mat, index) in mats" 
             class="img-thumbnail" :src="mat.thumbnail" 
             @click="_handleImagePreview({key: 'currentMatIndex',value: index})"
             :class="currentMatIndex == index ? 'activeClass' : ''"
             >
        </img>
      </div>
    </div>
  </div>
</div>

<style>
HTML SCSS JSResult Skip Results Iframe
EDIT ON
/** HTML ELEMENTS **/
body {
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/white_wall_hash.png');
  padding: 20px;
}
ul {
  list-style-type: none;
  padding: 0px;
}
h2 {
  text-align: center;
  margin-top: 0px;
}
img {
  width: 100%;
}

/** MAIN STYLES **/
#app {
  margin: 0 auto;
  display: flex;
  justify-content: center; 
  margin-bottom: 25px;
}

.main-wrapper {
  padding-left: 50px;
  padding-right: 50px;
  padding-top: 15px;
  padding-bottom: 50px;
  width: 400px;
  box-shadow: 0 3px 10px rgba(0,0,0,.075);
  background-color: white;
}
.img-main-wrapper {
  position: relative;
}
.img-absolute {
  position: absolute;
}
.content-row {
  text-align: center;
}

@media only screen and (max-width: 600px) {
  h2 {
    margin-bottom: 5px;
    font-size: 20px;
  }
  .main-wrapper{
    padding-top: 10px;
    padding-left: 30px;
    padding-right: 30px;
  }
  body {
    padding: 0px;
  }
}

/** CHOOSE ITEMS STYLES **/ 
.img-thumbnail-wrapper {
  display: flex;
  justify-content: space-evenly;
}
.img-thumbnail {
  box-sizing: border-box;
  width: 33%;
  max-width: 100px;
  margin-left: 10px;
  margin-right: 10px;
}

/** CONDITIONAL CLASSES **/
.activeClass {
  box-shadow: 0 15px 30px rgba(0,0,0,.4);
}

/** TRANSITIONS **/
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.20s ease-out;
}
.fade-enter, .fade-leave-to {
  opacity: 0;
}

/** PROGRESS BAR **/
.progress-bar {
  height: 5px;
  background-color: red;
}
View Compiled

Resources1× 0.5× 0.25×Rerun


</style>


<script>

var mainElement = new Vue({
  el: '#app',
  data() {
    return {
      progressBarOn: true,
      progressBar: 0,
      intervalProgress: undefined,
      intervalItem: undefined,
      currentChairIndex: undefined,
      currentMatIndex: undefined,
      mats: [
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/60173a0e1f52d4f447badd1af3c170e6%5B1%5D.png',
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/overlay-stand-mat-black%5B1%5D.png',
        },
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/cd8d9d636efc7bed2d7bb96d3925cd7c%5B1%5D.png',
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/topom-black%5B1%5D.png',
        },
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/09b6e9f4d055b575b094a9c85dc89594%5B1%5D.png',
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/fully-jarvis-standing-desk-floatdeck-balance-board-ov-01%5B1%5D.png',
        }
      ],
      chairs: [
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/09710f3d9e55a7f8ad2e8353327ac7ff%5B1%5D.png',
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/fully-luna-standing-desk-stool-jarvis-config-black-black-v01%5B1%5D.png',
        },
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/d0b4d1278dbe18b7c0c99753953a1e7b%5B1%5D.png',
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/config-ttc-natural-v2%5B1%5D.png'
        },
        {
          thumbnail: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/be784f6a320c39e063bba64cf936f09c%5B1%5D.png', 
          main: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/fully-jarvis-crank-config-8010-blackblack%5B1%5D.png'
        }
      ]
    }
  },
  methods: {
    /**
     * @params event is an object
     * key = type of item clicked
     * value = index passed in
     */
    _handleImagePreview(event){
      // Disable timer functionality
      clearInterval(this.intervalItem);
      clearInterval(this.intervalProgress);
      this.progressBarOn = false;
      
      // Show item clicked
      let index = event.value;
      let dataType = event.key;
      if(this[dataType] == index){
        this[dataType] = undefined;
      } else {
        this[dataType] = index;
      }
    },
  },
  mounted(){
    let progressCount = 0;
    let count = 0;
    let maxArrayLength = this.chairs.length;
    
    this.intervalProgress = setInterval(() => {
      this.progressBar = progressCount + '%'
      progressCount += 0.1111111; /* 100%/(9000/10) */
      if(progressCount > 100){
        progressCount = 0;
      }
    }, 10);
    
    this.intervalItem = setInterval(() =>{
      console.log("I ran");
      this.currentChairIndex = count;
      this.currentMatIndex = count;
      if(count < maxArrayLength - 1){
        count++;
      } else {
        count = 0;
      }
    },3000)
  }
});




</script>

multiple automatic slideshows pause on mouse hover

I’m practically useless at JavaScript so I need your help to add a “pause on mouse hover the slide” feature to this multiple slideshow. I tried to do this but it still is not working.

$(document).ready(function() {
  var slideshowContainers = document.getElementsByClassName("slideshow-container");
  var ref_dot = document.getElementsByClassName("banner-sell");
  
  for (let s = 0; s < slideshowContainers.length; s++) {
    var slides = slideshowContainers[s].querySelectorAll('.mySlides');
    var dot = ref_dot[s].querySelectorAll('.dot-banner');
    var slideIndexAuto = 0;
    showSlidesAuto(true, slides, slideIndexAuto, dot, slideshowContainers[s]);
  };
});

async function showSlidesAuto(status, slides, slideIndex, dots, el) {
  var stop = 0;
  
  $(el).mouseenter(function() {
    status = false;
  })
  
  if (status) {
    var no = (dots[0].classList[1]).replace('dot', '');
    var name_slides = 'mySlides' + no;
    var name_cart = 'cart-code' + no;
    var check_m = document.getElementsByClassName(name_slides);
    for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
    };

    for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
    }
    slideIndex++;

    if (slideIndex > slides.length) {
      slideIndex = 1
    };

    slides[slideIndex - 1].style.display = "block";
    dots[slideIndex - 1].className += " active";
    var menu_code = '';
    menu_code = slides[slideIndex - 1].getAttribute('data-menu');
    pro_code = slides[slideIndex - 1].getAttribute('data-code');
    $('.' + name_cart).attr('data-code', pro_code);
    $('.' + name_cart).attr('data-menu', menu_code);
    dtSlide = [slides, slideIndex, dots, el];
    sldtimeout = setTimeout(function() {
      if (isSlide) {
        showSlidesAuto(true, slides, slideIndex, dots, el)
      }
    }, 2000);
  }
};

how can i use the same page as an edit and an add and cache them offline with simple url change as in description

hi there so i have a link lets say it is https://example.com/exp
the exp page is my add page and it is cache in my service worker and works offline
now when i open my list and choose to edit a record it open is https://example.com/exp?id=2
when i open this page it doesnt work offline if i remove the id part then it works but then it is an add i want my edit page to be offline aswell
how do i fix this?

please help

my code**

// give your cache a name
const cacheName = 'my-cache';
// alert('hi')
// put the static assets and routes you want to cache here
const filesToCache = [
  
  
  '/',

 'https://example.com/exp',

];

// the event handler for the activate event
self.addEventListener('activate', e => self.clients.claim());

// the event handler for the install event 
// typically used to cache assets
self.addEventListener('install', e => {
  e.waitUntil(
    caches.open(cacheName)
    .then(cache => cache.addAll(filesToCache))
  );
});

// the fetch event handler, to intercept requests and serve all 
// static assets from the cache
self.addEventListener('fetch', e => {

  e.respondWith(
    caches.match(e.request)
    .then(response => response ? response : fetch(e.request))
  )


});

Ag grid external filtering with Tree Data not able to remove parent after filtering

We are using ag-grid version 25.0.1
We are having tree data such as

[
    {
      path: ['Ten'],
    },
    {
      path: ['Ten', 'Twenty'],
    },
    {
      path: ['Ten', 'Twenty', 'Thirty'],
    },
    {
      path: ['Ten', 'Twenty', 'Thirty', 'Fourty'],
    },
    {
      path: ['One'],
    },
    {
      path: ['One', 'Two'],
    },
    {
      path: ['One', 'Two', 'Three'],
    },
  ]

on applying an external filter with a value of Thirty https://www.ag-grid.com/javascript-data-grid/filter-external/. We are getting the result along with its parents as

[
    {
      path: ['Ten'],
    },
    {
      path: ['Ten', 'Twenty'],
    },
    {
      path: ['Ten', 'Twenty', 'Thirty'],
    }
]

Is there any way where we can exclude the parents on filter in Tree data and only filter the exact row that is satisfying the condition without getting any filler rows in ag-grid ?? i.e

[
    {
      path: ['Ten', 'Twenty', 'Thirty'],
    }
]

A slider through divs

can someone explain the code below with all functions like .ready() and .next().show().prev().hide();, .prev().show().next().hide();.
And if it’s possible, how can I do it JS only without JQuery?
Thanks in advance.

$(document).ready(function(){
    $(".divs div").each(function(e) {
        if (e != 0)
            $(this).hide();
    });

    $("#next").click(function(){
        if ($(".divs div:visible").next().length != 0)
            $(".divs div:visible").next().show().prev().hide();
        else {
            $(".divs div:visible").hide();
            $(".divs div:first").show();
        }
        return false;
    });

    $("#prev").click(function(){
        if ($(".divs div:visible").prev().length != 0)
            $(".divs div:visible").prev().show().next().hide();
        else {
            $(".divs div:visible").hide();
            $(".divs div:last").show();
        }
        return false;
    });
});
<div class="divs">
     <div class="cls1">1</div>
     <div class="cls2">2</div>
     <div class="cls3">3</div>
     <div class="cls4">4</div>
     <div class="cls5">5</div>
     <div class="cls6">6</div>
     <div class="cls7">7</div>
 </div>
 <a id="prev">prev</a>
 <a id="next">next</a>

https://codepen.io/Aurelian/pen/VaBYbZ?editors=1010

Is there any way to remove html element by context?

i have this following html code

<ui id="fruits">
    <li>apple</li>
    <li>orange</li>
    <li>banana</li>
    <li>lemon</li>
    <li>melon</li>
</ui>

now the question is: is there any function in jquery like $("#furits").removeElement("apple") to remove a element by context?

I tried the remove function in jquery, however it can only remove element by class,id,name etc, but i want remove a element by context?

thx.

React- Navlink error with Menu.item from semantic-ui

New to react, So a little confused on why this was giving me an error.

This is my main.js file

import React from 'react'
import { Menu, Segment } from 'semantic-ui-react'
import { Routes , Route, NavLink } from 'react-router-dom'

import HomeView from './HomeView'
import PowerSection from './PowerSection'


const Main = () => (
    <div>
        <Menu pointing secondary stackable>
            <Menu.Menu position='right'>
                <Menu.Item active  as={NavLink} exact to='/' name='Welcome' /> 
                <Menu.Item  as={NavLink} to='/powersection' name='power' />
            </Menu.Menu>
        </Menu>

        <Segment raised className='magentaSegment'>
            <Routes>
                <Route exact path='/' element={<HomeView />} />
                <Route path='/powersection' element={<PowerSection />} />
                {/* <Route path='*' component={NotFound} /> */}
            </Routes>
        </Segment>
    </div>
)

export default Main

This is what my App.js file looks like

import React from 'react'
import Main from '../components/Main'
import './App.css';
import { Route, Routes } from 'react-router-dom';
import Footer from '../components/Footer'

function App() {
  return (
    <div id='container'>
      <div id='main'>
        <Routes>
          <Route path='/' element={ <Main />} />
        </Routes>
      </div>

      <div id='footer'>
        <Footer />
      </div>
    </div>
  );
}

export default App;

And this is my index.js file.

import React from 'react';
import ReactDOM from 'react-dom/client';
import 'semantic-ui-css/semantic.min.css'
import './index.css';
import App from './containers/App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter } from 'react-router-dom'

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <BrowserRouter>
    <App />
  </BrowserRouter>
);

reportWebVitals();

When I toggle to the Power menu item. this is the error i get
index.js:44 No routes matched location “/powersection”

Anyone know how i can fix this? Thank you

Warning – DataTables warning: table id=example – Cannot reinitialise DataTable

I am trying to get data from .JSON file and filter it in realtime.
But I am getting Warnings as

DataTables warning: table id=example – Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

As per instructions in above link I added retrieve: true, and paging: false, But still warnings are shown.
I am new for jscript and jquery so can you please help me to resolve this warning

main.js file

$(document).ready(function () {
    var table = $('#example').DataTable({
        retrieve: true,
        
        paging: false,

        ajax: {
            url: './test.json',
            dataSrc: '',
        },
        
        columns: [
            { data: 'Host' },
            { data: 'Category' },
            { data: 'Type' },
            { data: 'SSH' },
            { data: 'Status' },
            { data: 'Notes' },
        ],
        
        mark: true,
        
        dom: 'Bfrtip',
        lengthMenu: [
            [10, 25, 50, 100, -1],
            ['10 rows', '25 rows', '50 rows', '100 rows', 'Show All']
        ],
        
        buttons: [
            'pageLength',
            {
                extend: 'copyHtml5',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'excelHtml5',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'csvHtml5',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'print',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'pdfHtml5',
                download: 'open',
                exportOptions: {
                    columns: ':visible'
                }
            },
            'colvis'
        ],
        
        columDefs: [{
            targets: -1,
            visible: false
        }],

    });

    $('#example tfoot th').each(function () {
        var title = $('#example tfoot th').eq($(this).index()).text();
        $(this).html('<input type="text" placeholder="Search ' + title + '" />');
    });

    table.columns().eq(0).each(function (colIdx) {
        $('input', table.column(colIdx).footer()).on('keyup change', function () {
            table
                .column(colIdx)
                .search(this.value)
                .draw();
        });
    });
});

I’m getting this error: expected [ ” ] to deeply equal [], but it works fine on vs code

This was the question from codewars:

Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore (‘_’).

Examples:

  • ‘abc’ => [‘ab’, ‘c_’]
  • ‘abcdef’ => [‘ab’, ‘cd’, ‘ef’]

And this is what i have achieved:

function solution(str) {
      const letters = str.split('');
      let text = '';
      for (const letter of letters) {
        text += letter;
        if (text.replace(/ /g, '').length % 2 === 0)
          letter !== letters[letters.length - 1] && (text += ' ');
      }
      if (str.length % 2 !== 0) text += '_';
      return text.split(' ');
    }
    
    console.log(solution('abcd'));

This is the error, i’m getting: expected [ ” ] to deeply equal []

A screenshot from codewars

Accessing Google Form Settings using Google Apps Script

I have a Google Apps Script auto-create a Google Form based on certain cell data, but since the script is using my corporate email to create the form, it is restricting access to view the form to only organization members. I have to manually go into the form settings to disable this user restriction.

Is there a way to access the setting via Apps Script and turn it off for each form created, either:

  1. Programmatically (did not find anything in documentation to change this setting)
  2. Macro (accessing the edit URL and emulate a click on the button via Apps Script?)