Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js check if field in database is true or false

let taskDone = document.querySelectorAll('.taskDone'); //get all the chechbox with same class .taskDone
taskDone.forEach(function(btn) { //use normal function
  btn.addEventListener('change', function() {
    let id = $(this).data('id') //get the data id of checkbox
    if ($(this).is(':checked')) { //check if the clicked checkbox is checked or not
      console.log(id + ' is Checked - Updating neDB') //console.log
      $.ajax({
        url: 'http://localhost:3000/done/' + id,
        type: 'PUT',
        data: 'isDone'
      }).done(function(data) {
        console.log(data)
      })
    } else {
      console.log("Not Checked")
    }
  })
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: adding number in an array using the .forEach() method in javascript 
Javascript :: requiere and get a property simplified with Node 
Javascript :: moment js get dd/mm/yyyy 
Javascript :: remove last word over a limit javascript 
Javascript :: jeebisah 
Javascript :: if strings in array 
Javascript :: clickjacking in react js 
Javascript :: jquery dropdownlist from mvc jsonresult list 
Javascript :: "create a chatbot using javascript only" 
Javascript :: how to send varible to another page in nuxt.js 
Javascript :: firebase messaging service not working with electron 
Javascript :: Including soft deleted records 
Javascript :: where in typeorm 
Javascript :: ASPxGridView - How to trigger the CustomButtonCallback event 
Javascript :: java script loup object 
Javascript :: array object make api format javascript 
Javascript :: react native asyncstorage mergeItem 
Javascript :: microseconds to current time js code 
Javascript :: VM360:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 
Javascript :: node_modulesexpresslib outerindex.js:508 this.stack.push(layer); 
Javascript :: sentry not working in frontend 
Javascript :: how we pass 2 args in switch case javascript 
Javascript :: typeorm caching queries limit 
Javascript :: how to test conditional rendering vue test utils 
Javascript :: change style selected text js 
Javascript :: Example of AggregateError in es12 
Javascript :: golang json time 
Javascript :: Getting error after I put Async function in useEffect 
Javascript :: maxscript saveMaxFile 
Javascript :: open failed: EACCES (Permission denied) react native 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =