Delete records from a table (Firebase)Add table row in jQueryHow do I remove a property from a JavaScript object?Deleting array elements in JavaScript - delete vs spliceGet selected text from a drop-down list (select box) using jQueryRedirect from an HTML pageHow do I remove a particular element from an array in JavaScript?jQuery Get Selected Option From DropdownHow do I return the response from an asynchronous call?Cannot display HTML stringHow to display table created using multiple type input values from a form to another page after hitting submit button?

Send a single HTML email from Thunderbird, overriding the default "plain text" setting

Is it legal to use cash pulled from a credit card to pay the monthly payment on that credit card?

Spin vs orbital angular momenta in QFT

How acidic does a mixture have to be for milk to curdle?

What does "see" in "the Holy See" mean?

Why was Sauron preparing for war instead of trying to find the ring?

Request for a Latin phrase as motto "God is highest/supreme"

Is there anything wrong with Thrawn?

Strange Cron Job takes up 100% of CPU Ubuntu 18 LTS Server

Commercial jet accompanied by small plane near Seattle

3D Statue Park: U shapes

How do I run a game when my PCs have different approaches to combat?

Why did Saturn V not head straight to the moon?

How important is a good quality camera for good photography?

Giant alien flies into the solar system; the rocky planets are its eggs

Drillers for petroleum strike gusher of blood

Why are so many countries still in the Commonwealth?

Is my employer paying me fairly? Going from 1099 to W2

Trying to build a function to compute divided difference for arbitrary list of points

Does the Intel 8086 CPU have user mode and kernel mode?

Why/when is AC-DC-AC conversion superior to direct AC-Ac conversion?

How do campaign rallies gain candidates votes?

What do teaching faculty do during semester breaks?

Basic Questions on Wiener Filtering



Delete records from a table (Firebase)


Add table row in jQueryHow do I remove a property from a JavaScript object?Deleting array elements in JavaScript - delete vs spliceGet selected text from a drop-down list (select box) using jQueryRedirect from an HTML pageHow do I remove a particular element from an array in JavaScript?jQuery Get Selected Option From DropdownHow do I return the response from an asynchronous call?Cannot display HTML stringHow to display table created using multiple type input values from a form to another page after hitting submit button?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I do not know how to delete the specific record when I click the img on the right



I want it to work like that:



enter image description here



Also I put an img for delete the specific record but I do not know how to add an event listener on img in the JS to delete the row and the record. Also, when I insert data in the DB I add the UID of the specific object for the delete purposes.



HTML code



<html>
<head>
<title>Fall-App Admin Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<LINK rel="stylesheet" href="style.css" type="text/css" media="all">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.8.6/firebase.js"></script>
</head>

<body>
<div class="cabecera">

</div>

<div class="cuerpo">
<div class="botones">
<table style="background-color:grey;height:100%; width:99%" border="10" id="logout">
<tr><td><a href="socialServices.html">Επεξεργασία Κοινωνικών Υπηρεσιών</a></td></tr>
<tr><td><a href="index.html"id="logout">Αποσύνδεση</a></td></tr>
</table>

</div>

<div class="welcome">
<div class="container">
<!--<form>
<input class="input" type="text" id="searchTxt" placeholder="Αναζήτηση για ...">
<input class="submit" type="submit" id="searchBtn" value="Εύρεση">
</form>-->
<input type="text" placeholder="Επιβεβαίωση Κωδικού" name="rePsw" id="rePswReg" required>
<button type="submit" id="searchBtn">Εγγραφή</button>

<table class="searchTable" style="width:100%">
<thead>
<tr>
<td>Name Of Service</td>
<td>Address</td>
<td>Postal</td>
<td>City</td>
<td>Phone</td>
<td>Delete</td>
</tr>
</thead>
<tbody id="tableBody">

</tbody>
</table>
</div>

<form id="submitForm">
Name Of Service:<br>
<input type="text" name="name" id="nameDB"><br>
Address:<br>
<input type="text" name="address" id="addressDB">
Postal:<br>
<input type="text" name="postal" id="postalDB">
City:<br>
<input type="text" name="city" id="cityDB">
Phone:<br>
<input type="text" name="phone" id="phoneDB">

<button type="submit" id="btnInsert">Inster</button>
</form>

<script src="registered.js"></script>
</div>
</div>

<div class="pie">

</div>
</body>
</html>


JS code



 (function() 

//initialize Firebase
var config =

;
firebase.initializeApp(config);


const searchBtn = document.getElementById('searchBtn');
//const searchTxt = document.getElementById('searchTxt');

var messagesRef2 = firebase.database().ref().child('socialServices');
var counter=-1;


//bring all to the table
var messagesRef2 = firebase.database().ref().child('socialServices');

messagesRef2.on("child_added", snap =>
counter++;
var name=snap.child("name").val();
var address=snap.child("address").val();
var postal=snap.child("postal").val();
var city=snap.child("city").val();
var phone=snap.child("phone").val();

$("#tableBody").append("<tr><td>" + name + "</td><td>" + address + "</td><td>" +
postal + "</td><td>" + city + "</td><td>" + phone + "</td><td>" + "<img src='http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Close-icon.png' id='Img'>" + "</td></tr>");
);


//regerence messages collection
var messagesRef = firebase.database().ref('socialServices');

//listen for form submit
document.getElementById('submitForm').addEventListener('submit', submitForm);


//submit form
function submitForm(e)
e.preventDefault();

//get values
var name=getInputVal('nameDB');
var address=getInputVal('addressDB');
var postal=getInputVal('postalDB');
var city=getInputVal('cityDB');
var phone=getInputVal('phoneDB');

//save message
saveMessage(name, address, postal, city, phone);


//function to get form values
function getInputVal(id)
return document.getElementById(id).value;


//save message to firebase
function saveMessage(name, address, postal, city, phone)
var newMessageRef = messagesRef.push();
newMessageRef.set(
id: newMessageRef.key,
name: name,
address: address,
postal: postal,
city: city,
phone: phone
);


());









share|improve this question






























    1















    I do not know how to delete the specific record when I click the img on the right



    I want it to work like that:



    enter image description here



    Also I put an img for delete the specific record but I do not know how to add an event listener on img in the JS to delete the row and the record. Also, when I insert data in the DB I add the UID of the specific object for the delete purposes.



    HTML code



    <html>
    <head>
    <title>Fall-App Admin Panel</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <LINK rel="stylesheet" href="style.css" type="text/css" media="all">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://www.gstatic.com/firebasejs/5.8.6/firebase.js"></script>
    </head>

    <body>
    <div class="cabecera">

    </div>

    <div class="cuerpo">
    <div class="botones">
    <table style="background-color:grey;height:100%; width:99%" border="10" id="logout">
    <tr><td><a href="socialServices.html">Επεξεργασία Κοινωνικών Υπηρεσιών</a></td></tr>
    <tr><td><a href="index.html"id="logout">Αποσύνδεση</a></td></tr>
    </table>

    </div>

    <div class="welcome">
    <div class="container">
    <!--<form>
    <input class="input" type="text" id="searchTxt" placeholder="Αναζήτηση για ...">
    <input class="submit" type="submit" id="searchBtn" value="Εύρεση">
    </form>-->
    <input type="text" placeholder="Επιβεβαίωση Κωδικού" name="rePsw" id="rePswReg" required>
    <button type="submit" id="searchBtn">Εγγραφή</button>

    <table class="searchTable" style="width:100%">
    <thead>
    <tr>
    <td>Name Of Service</td>
    <td>Address</td>
    <td>Postal</td>
    <td>City</td>
    <td>Phone</td>
    <td>Delete</td>
    </tr>
    </thead>
    <tbody id="tableBody">

    </tbody>
    </table>
    </div>

    <form id="submitForm">
    Name Of Service:<br>
    <input type="text" name="name" id="nameDB"><br>
    Address:<br>
    <input type="text" name="address" id="addressDB">
    Postal:<br>
    <input type="text" name="postal" id="postalDB">
    City:<br>
    <input type="text" name="city" id="cityDB">
    Phone:<br>
    <input type="text" name="phone" id="phoneDB">

    <button type="submit" id="btnInsert">Inster</button>
    </form>

    <script src="registered.js"></script>
    </div>
    </div>

    <div class="pie">

    </div>
    </body>
    </html>


    JS code



     (function() 

    //initialize Firebase
    var config =

    ;
    firebase.initializeApp(config);


    const searchBtn = document.getElementById('searchBtn');
    //const searchTxt = document.getElementById('searchTxt');

    var messagesRef2 = firebase.database().ref().child('socialServices');
    var counter=-1;


    //bring all to the table
    var messagesRef2 = firebase.database().ref().child('socialServices');

    messagesRef2.on("child_added", snap =>
    counter++;
    var name=snap.child("name").val();
    var address=snap.child("address").val();
    var postal=snap.child("postal").val();
    var city=snap.child("city").val();
    var phone=snap.child("phone").val();

    $("#tableBody").append("<tr><td>" + name + "</td><td>" + address + "</td><td>" +
    postal + "</td><td>" + city + "</td><td>" + phone + "</td><td>" + "<img src='http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Close-icon.png' id='Img'>" + "</td></tr>");
    );


    //regerence messages collection
    var messagesRef = firebase.database().ref('socialServices');

    //listen for form submit
    document.getElementById('submitForm').addEventListener('submit', submitForm);


    //submit form
    function submitForm(e)
    e.preventDefault();

    //get values
    var name=getInputVal('nameDB');
    var address=getInputVal('addressDB');
    var postal=getInputVal('postalDB');
    var city=getInputVal('cityDB');
    var phone=getInputVal('phoneDB');

    //save message
    saveMessage(name, address, postal, city, phone);


    //function to get form values
    function getInputVal(id)
    return document.getElementById(id).value;


    //save message to firebase
    function saveMessage(name, address, postal, city, phone)
    var newMessageRef = messagesRef.push();
    newMessageRef.set(
    id: newMessageRef.key,
    name: name,
    address: address,
    postal: postal,
    city: city,
    phone: phone
    );


    ());









    share|improve this question


























      1












      1








      1








      I do not know how to delete the specific record when I click the img on the right



      I want it to work like that:



      enter image description here



      Also I put an img for delete the specific record but I do not know how to add an event listener on img in the JS to delete the row and the record. Also, when I insert data in the DB I add the UID of the specific object for the delete purposes.



      HTML code



      <html>
      <head>
      <title>Fall-App Admin Panel</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <LINK rel="stylesheet" href="style.css" type="text/css" media="all">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.8.6/firebase.js"></script>
      </head>

      <body>
      <div class="cabecera">

      </div>

      <div class="cuerpo">
      <div class="botones">
      <table style="background-color:grey;height:100%; width:99%" border="10" id="logout">
      <tr><td><a href="socialServices.html">Επεξεργασία Κοινωνικών Υπηρεσιών</a></td></tr>
      <tr><td><a href="index.html"id="logout">Αποσύνδεση</a></td></tr>
      </table>

      </div>

      <div class="welcome">
      <div class="container">
      <!--<form>
      <input class="input" type="text" id="searchTxt" placeholder="Αναζήτηση για ...">
      <input class="submit" type="submit" id="searchBtn" value="Εύρεση">
      </form>-->
      <input type="text" placeholder="Επιβεβαίωση Κωδικού" name="rePsw" id="rePswReg" required>
      <button type="submit" id="searchBtn">Εγγραφή</button>

      <table class="searchTable" style="width:100%">
      <thead>
      <tr>
      <td>Name Of Service</td>
      <td>Address</td>
      <td>Postal</td>
      <td>City</td>
      <td>Phone</td>
      <td>Delete</td>
      </tr>
      </thead>
      <tbody id="tableBody">

      </tbody>
      </table>
      </div>

      <form id="submitForm">
      Name Of Service:<br>
      <input type="text" name="name" id="nameDB"><br>
      Address:<br>
      <input type="text" name="address" id="addressDB">
      Postal:<br>
      <input type="text" name="postal" id="postalDB">
      City:<br>
      <input type="text" name="city" id="cityDB">
      Phone:<br>
      <input type="text" name="phone" id="phoneDB">

      <button type="submit" id="btnInsert">Inster</button>
      </form>

      <script src="registered.js"></script>
      </div>
      </div>

      <div class="pie">

      </div>
      </body>
      </html>


      JS code



       (function() 

      //initialize Firebase
      var config =

      ;
      firebase.initializeApp(config);


      const searchBtn = document.getElementById('searchBtn');
      //const searchTxt = document.getElementById('searchTxt');

      var messagesRef2 = firebase.database().ref().child('socialServices');
      var counter=-1;


      //bring all to the table
      var messagesRef2 = firebase.database().ref().child('socialServices');

      messagesRef2.on("child_added", snap =>
      counter++;
      var name=snap.child("name").val();
      var address=snap.child("address").val();
      var postal=snap.child("postal").val();
      var city=snap.child("city").val();
      var phone=snap.child("phone").val();

      $("#tableBody").append("<tr><td>" + name + "</td><td>" + address + "</td><td>" +
      postal + "</td><td>" + city + "</td><td>" + phone + "</td><td>" + "<img src='http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Close-icon.png' id='Img'>" + "</td></tr>");
      );


      //regerence messages collection
      var messagesRef = firebase.database().ref('socialServices');

      //listen for form submit
      document.getElementById('submitForm').addEventListener('submit', submitForm);


      //submit form
      function submitForm(e)
      e.preventDefault();

      //get values
      var name=getInputVal('nameDB');
      var address=getInputVal('addressDB');
      var postal=getInputVal('postalDB');
      var city=getInputVal('cityDB');
      var phone=getInputVal('phoneDB');

      //save message
      saveMessage(name, address, postal, city, phone);


      //function to get form values
      function getInputVal(id)
      return document.getElementById(id).value;


      //save message to firebase
      function saveMessage(name, address, postal, city, phone)
      var newMessageRef = messagesRef.push();
      newMessageRef.set(
      id: newMessageRef.key,
      name: name,
      address: address,
      postal: postal,
      city: city,
      phone: phone
      );


      ());









      share|improve this question
















      I do not know how to delete the specific record when I click the img on the right



      I want it to work like that:



      enter image description here



      Also I put an img for delete the specific record but I do not know how to add an event listener on img in the JS to delete the row and the record. Also, when I insert data in the DB I add the UID of the specific object for the delete purposes.



      HTML code



      <html>
      <head>
      <title>Fall-App Admin Panel</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <LINK rel="stylesheet" href="style.css" type="text/css" media="all">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.8.6/firebase.js"></script>
      </head>

      <body>
      <div class="cabecera">

      </div>

      <div class="cuerpo">
      <div class="botones">
      <table style="background-color:grey;height:100%; width:99%" border="10" id="logout">
      <tr><td><a href="socialServices.html">Επεξεργασία Κοινωνικών Υπηρεσιών</a></td></tr>
      <tr><td><a href="index.html"id="logout">Αποσύνδεση</a></td></tr>
      </table>

      </div>

      <div class="welcome">
      <div class="container">
      <!--<form>
      <input class="input" type="text" id="searchTxt" placeholder="Αναζήτηση για ...">
      <input class="submit" type="submit" id="searchBtn" value="Εύρεση">
      </form>-->
      <input type="text" placeholder="Επιβεβαίωση Κωδικού" name="rePsw" id="rePswReg" required>
      <button type="submit" id="searchBtn">Εγγραφή</button>

      <table class="searchTable" style="width:100%">
      <thead>
      <tr>
      <td>Name Of Service</td>
      <td>Address</td>
      <td>Postal</td>
      <td>City</td>
      <td>Phone</td>
      <td>Delete</td>
      </tr>
      </thead>
      <tbody id="tableBody">

      </tbody>
      </table>
      </div>

      <form id="submitForm">
      Name Of Service:<br>
      <input type="text" name="name" id="nameDB"><br>
      Address:<br>
      <input type="text" name="address" id="addressDB">
      Postal:<br>
      <input type="text" name="postal" id="postalDB">
      City:<br>
      <input type="text" name="city" id="cityDB">
      Phone:<br>
      <input type="text" name="phone" id="phoneDB">

      <button type="submit" id="btnInsert">Inster</button>
      </form>

      <script src="registered.js"></script>
      </div>
      </div>

      <div class="pie">

      </div>
      </body>
      </html>


      JS code



       (function() 

      //initialize Firebase
      var config =

      ;
      firebase.initializeApp(config);


      const searchBtn = document.getElementById('searchBtn');
      //const searchTxt = document.getElementById('searchTxt');

      var messagesRef2 = firebase.database().ref().child('socialServices');
      var counter=-1;


      //bring all to the table
      var messagesRef2 = firebase.database().ref().child('socialServices');

      messagesRef2.on("child_added", snap =>
      counter++;
      var name=snap.child("name").val();
      var address=snap.child("address").val();
      var postal=snap.child("postal").val();
      var city=snap.child("city").val();
      var phone=snap.child("phone").val();

      $("#tableBody").append("<tr><td>" + name + "</td><td>" + address + "</td><td>" +
      postal + "</td><td>" + city + "</td><td>" + phone + "</td><td>" + "<img src='http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Close-icon.png' id='Img'>" + "</td></tr>");
      );


      //regerence messages collection
      var messagesRef = firebase.database().ref('socialServices');

      //listen for form submit
      document.getElementById('submitForm').addEventListener('submit', submitForm);


      //submit form
      function submitForm(e)
      e.preventDefault();

      //get values
      var name=getInputVal('nameDB');
      var address=getInputVal('addressDB');
      var postal=getInputVal('postalDB');
      var city=getInputVal('cityDB');
      var phone=getInputVal('phoneDB');

      //save message
      saveMessage(name, address, postal, city, phone);


      //function to get form values
      function getInputVal(id)
      return document.getElementById(id).value;


      //save message to firebase
      function saveMessage(name, address, postal, city, phone)
      var newMessageRef = messagesRef.push();
      newMessageRef.set(
      id: newMessageRef.key,
      name: name,
      address: address,
      postal: postal,
      city: city,
      phone: phone
      );


      ());






      javascript html firebase






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 15:05









      Curr195

      1,3123 gold badges16 silver badges35 bronze badges




      1,3123 gold badges16 silver badges35 bronze badges










      asked Mar 26 at 14:41









      zouvezouve

      255 bronze badges




      255 bronze badges






















          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359883%2fdelete-records-from-a-table-firebase%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359883%2fdelete-records-from-a-table-firebase%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해