jeudi 11 avril 2019

How to send funtion result with POST

I have a dynamic html table. On the first column I have checkboxes. I would like to send with POST the data from the second column where the checkbox is checked on the first column.

The following function gets me the data in the second column where the checkbox is checked.

    function myFunction() {
    //Reference the Table.
    var grid = document.getElementById("myTable");

    //Reference the CheckBoxes in Table.
    var checkBoxes = grid.getElementsByTagName("INPUT");
    /* var message = "mac\n"; */
    var message = "";

    //Loop through the CheckBoxes.
    for (var i = 0; i < checkBoxes.length; i++) {
        if (checkBoxes[i].checked) {
            var row = checkBoxes[i].parentNode.parentNode;
            message += row.cells[1].innerHTML;

            message += "\n";
        }
    }

    //Display selected Row data in Alert Box.
    alert(message);
    }

And when I press the button: Click me This pops up an alert window with the value of rows I have sellected.

I would like to send the value of the function to another php file using POST and not show the alert message.

I tryed multiple ways with forms but I dont know how to assing the value returned by the function in to a variable in the form. (for example assign it to a hidden input type) Can someone guide me on the right track.

Thanks




Aucun commentaire:

Enregistrer un commentaire