Demo entry 5862463

mypythoncode

   

Submitted by anonymous on Aug 04, 2016 at 22:12
Language: JavaScript. Code size: 1.2 kB.

      // for inserting data we need a table id, which is obtained from the input field ("getElementByID")
      // and the actual values
      function insertData() {
        var insert_tableid = document.getElementById('insert_tableid').value;
        if(insert_tableid) {
          tableId = insert_tableid;
        }
       // here the input values are predefined in advance and retrieved from input fields 
        var released = document.getElementById('released').value;
        var name = document.getElementById('name').value;
        var boxoffice = document.getElementById('boxoffice').value;
        
        // to build up the actual query an array "insert" is used and compiled with the "push" function
        var insert = [];
        insert.push('INSERT INTO ');
        insert.push(tableId);
        insert.push(" ('Released', 'Film Name', 'Total Box Office') VALUES (");
        insert.push(released);
        insert.push(",'" + name + "', ");
        insert.push(boxoffice);
        insert.push(')');

        // the array elements are concatenated with the join function and 
        // send of as an argument to the query function, which was explained previously 
        query(insert.join(''));
      }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).