-2
<form action = "AnotherPage.php" method = "get">
    <table id="uniqueID">
        <tr>
            <td><input id="box1" type="checkbox" name="box1" value = "apple"/><label
                    for="box1">apples</label></td>
        </tr>

    </table>
    <input type="submit" value="Submit">

</form>

so when the user submits it how would I grab that box1 = apple information in the anotherPage.html. Thanks preferably no jquery. So I want the anotherPage.html file to do console.log(box 1 = apple) and in the html file of anotherPage. "box 1 = apple" (without hard coding them of course)

EDIT. So I think it's better to do it with php. How would I echo this data in the AnotherPage.php

1 Answers1

0

If you want to use plain HTML & JS without any back-end server, you can send form data with GET method to next page as URI query parameter:

<form action = "anotherPage.html" method = "get">
    <table id="uniqueID">
        <tr>
            <td><input id="box1" type="checkbox" name="box1" value = "apple"/><label
                    for="box1">apples</label></td>
        </tr>

    </table>
    <input type="submit" value="Submit">
</form>

And cparse it from URI query on next page:

<html>
  <body>
  <script>
    const urlParams = new URLSearchParams(window.location.search);
    const apples = urlParams.get('box1');
    console.log(apples);
  </script>
  </body>
</html>
0x0a601
  • 16