Uncaught TypeError: Cannot read property 'submit' of undefined

Uncaught TypeError: Cannot read property 'submit' of undefined

ITCITC Posts: 9Questions: 0Answers: 0

cropping.it/Server_side_process_datatable/index.php

Hi,
I have put an URL in the CF_PIVA field, which should open a new page once it is clicked. Now i have two problems:
1- when i try to open the link, the frm.submit returns the error (Uncaught TypeError: Cannot read property 'submit' of undefined).
2- How can i see row of the table in the new page?
Is there someone who can give me some advice? Thank you

 <form id="frm-main" action=""  method="POST">
       <input type="hidden" name="CF_PIVA" value="">


$(document).ready(function() {
      var table = $('#AZIENDE_TEST').DataTable({
         "processing": true,
          "serverSide":true,
        "ajax": {
          url: "data.php"
        },
        columnDefs: [{
          targets: 9,
          render: function(data, type, row, meta) {
            if (type === 'display') {
              data = '<a class="link-post" href="http://cropping.it/Server_side_process_datatable/index.php/'+data+'" >' + data + '</a>';
            }
            return data;
          }
        }]
      });
      // Handle click on link in the table
      $('#AZIENDE_TEST').on('click', '.link-post','_blank', function(e) {
        e.preventDefault();

        // Get row data
        var data = table.row($(this).closest('tr')).data();

        var form = $('#frm-main').get(9);

        // Update form action URL if needed
         // form['action'] = this.href;

        // Set required form parameters
         // form['name'].value = data[9];

        // Submit form
        this.form.submit();
      });
    });
    </script>

Replies

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    Just took a look at this in chrome.
    This line is not working and returns undefined. Hence "form" is undefined.

    var form = $('#frm-main').get(9);

    I think this not related to data tables. Maybe stack overflow would be the better place to get an answer on this?! Or is there anyone else who has a solution?

  • ITCITC Posts: 9Questions: 0Answers: 0

    Adjournment.

    I have solved the problem with the submit form now it's working, but i still have the problem to retrive the clicked row in the new page.
    Is there someone who can help me?

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    Sorry, I can't follow this. What is the "new page"?
    I think you would need to post a test case as per the forum rules please.

This discussion has been closed.