One submit button for several textarea fields php/html












0















I am working on this table in which there will be 10 different projects (Jupiter, Uranus, Saturn, etc..) and in each row, there is a comment section for the user to add updates. As shown in the screenshots, each row has its own "add record" button but I want there to be one "submit" button at the bottom of the table to update multiple comment sections.
Currently, only one textarea can be submitted.
enter image description here



Here is a snip from the table file:



 echo "<h3> Welcome ". $username; 
echo "<h3> Form Data </h3>";
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text1" rows="2" cols=15></textarea>
<input type="submit" name="value1" value="Add Record">
</form>
<?php "</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text2" rows="2" cols=15></textarea>
<input type="submit" name="value2" value="Add Record">
</form> <?php


echo "</table>";


Here is a snip from the summary file:



    <?php


$PC1 = $_POST["text1"];
$PC2 = $_POST["text2"];

//Display in table
echo "Table updated by: " .$_SESSION['appusername'];
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>$PC1</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>$PC2</td>
</tr>";

echo "</table>";



?>
</body>


Any advice would be excellent










share|improve this question























  • What do you mean "only one textarea can be submitted"?

    – Jeto
    Nov 19 '18 at 19:54











  • If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

    – Stackhouse
    Nov 19 '18 at 19:56











  • I mean that only one comment can be submitted the way it is now

    – Stackhouse
    Nov 19 '18 at 19:57











  • Well, you have two forms, seems like you just need one. Put the whole table inside it.

    – Jeto
    Nov 19 '18 at 19:59













  • You have multiple forms. Just wrap the textareas in one form with one submit button.

    – AbraCadaver
    Nov 19 '18 at 19:59
















0















I am working on this table in which there will be 10 different projects (Jupiter, Uranus, Saturn, etc..) and in each row, there is a comment section for the user to add updates. As shown in the screenshots, each row has its own "add record" button but I want there to be one "submit" button at the bottom of the table to update multiple comment sections.
Currently, only one textarea can be submitted.
enter image description here



Here is a snip from the table file:



 echo "<h3> Welcome ". $username; 
echo "<h3> Form Data </h3>";
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text1" rows="2" cols=15></textarea>
<input type="submit" name="value1" value="Add Record">
</form>
<?php "</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text2" rows="2" cols=15></textarea>
<input type="submit" name="value2" value="Add Record">
</form> <?php


echo "</table>";


Here is a snip from the summary file:



    <?php


$PC1 = $_POST["text1"];
$PC2 = $_POST["text2"];

//Display in table
echo "Table updated by: " .$_SESSION['appusername'];
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>$PC1</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>$PC2</td>
</tr>";

echo "</table>";



?>
</body>


Any advice would be excellent










share|improve this question























  • What do you mean "only one textarea can be submitted"?

    – Jeto
    Nov 19 '18 at 19:54











  • If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

    – Stackhouse
    Nov 19 '18 at 19:56











  • I mean that only one comment can be submitted the way it is now

    – Stackhouse
    Nov 19 '18 at 19:57











  • Well, you have two forms, seems like you just need one. Put the whole table inside it.

    – Jeto
    Nov 19 '18 at 19:59













  • You have multiple forms. Just wrap the textareas in one form with one submit button.

    – AbraCadaver
    Nov 19 '18 at 19:59














0












0








0








I am working on this table in which there will be 10 different projects (Jupiter, Uranus, Saturn, etc..) and in each row, there is a comment section for the user to add updates. As shown in the screenshots, each row has its own "add record" button but I want there to be one "submit" button at the bottom of the table to update multiple comment sections.
Currently, only one textarea can be submitted.
enter image description here



Here is a snip from the table file:



 echo "<h3> Welcome ". $username; 
echo "<h3> Form Data </h3>";
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text1" rows="2" cols=15></textarea>
<input type="submit" name="value1" value="Add Record">
</form>
<?php "</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text2" rows="2" cols=15></textarea>
<input type="submit" name="value2" value="Add Record">
</form> <?php


echo "</table>";


Here is a snip from the summary file:



    <?php


$PC1 = $_POST["text1"];
$PC2 = $_POST["text2"];

//Display in table
echo "Table updated by: " .$_SESSION['appusername'];
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>$PC1</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>$PC2</td>
</tr>";

echo "</table>";



?>
</body>


Any advice would be excellent










share|improve this question














I am working on this table in which there will be 10 different projects (Jupiter, Uranus, Saturn, etc..) and in each row, there is a comment section for the user to add updates. As shown in the screenshots, each row has its own "add record" button but I want there to be one "submit" button at the bottom of the table to update multiple comment sections.
Currently, only one textarea can be submitted.
enter image description here



Here is a snip from the table file:



 echo "<h3> Welcome ". $username; 
echo "<h3> Form Data </h3>";
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text1" rows="2" cols=15></textarea>
<input type="submit" name="value1" value="Add Record">
</form>
<?php "</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>";?> <form action = 'summary.php' method="post">
<textarea name="text2" rows="2" cols=15></textarea>
<input type="submit" name="value2" value="Add Record">
</form> <?php


echo "</table>";


Here is a snip from the summary file:



    <?php


$PC1 = $_POST["text1"];
$PC2 = $_POST["text2"];

//Display in table
echo "Table updated by: " .$_SESSION['appusername'];
echo "<table border='1'>";
echo "<tr>
<th>Project</th>
<th>%Completed</th>
<th>Comments</th>
</tr>";
echo "<tr>
<td>Jupiter</td>
<td>78%</td>
<td>$PC1</td>
</tr>";
echo "<tr>
<td>Uranus</td>
<td>69%</td>
<td>$PC2</td>
</tr>";

echo "</table>";



?>
</body>


Any advice would be excellent







php html






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 19:48









StackhouseStackhouse

266




266













  • What do you mean "only one textarea can be submitted"?

    – Jeto
    Nov 19 '18 at 19:54











  • If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

    – Stackhouse
    Nov 19 '18 at 19:56











  • I mean that only one comment can be submitted the way it is now

    – Stackhouse
    Nov 19 '18 at 19:57











  • Well, you have two forms, seems like you just need one. Put the whole table inside it.

    – Jeto
    Nov 19 '18 at 19:59













  • You have multiple forms. Just wrap the textareas in one form with one submit button.

    – AbraCadaver
    Nov 19 '18 at 19:59



















  • What do you mean "only one textarea can be submitted"?

    – Jeto
    Nov 19 '18 at 19:54











  • If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

    – Stackhouse
    Nov 19 '18 at 19:56











  • I mean that only one comment can be submitted the way it is now

    – Stackhouse
    Nov 19 '18 at 19:57











  • Well, you have two forms, seems like you just need one. Put the whole table inside it.

    – Jeto
    Nov 19 '18 at 19:59













  • You have multiple forms. Just wrap the textareas in one form with one submit button.

    – AbraCadaver
    Nov 19 '18 at 19:59

















What do you mean "only one textarea can be submitted"?

– Jeto
Nov 19 '18 at 19:54





What do you mean "only one textarea can be submitted"?

– Jeto
Nov 19 '18 at 19:54













If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

– Stackhouse
Nov 19 '18 at 19:56





If you refer to the screenshots, in each comment section of each table, there is an "add record" comment. I need to just have comment boxes in each row but only one "add records" button to submit multiple comments all at once.

– Stackhouse
Nov 19 '18 at 19:56













I mean that only one comment can be submitted the way it is now

– Stackhouse
Nov 19 '18 at 19:57





I mean that only one comment can be submitted the way it is now

– Stackhouse
Nov 19 '18 at 19:57













Well, you have two forms, seems like you just need one. Put the whole table inside it.

– Jeto
Nov 19 '18 at 19:59







Well, you have two forms, seems like you just need one. Put the whole table inside it.

– Jeto
Nov 19 '18 at 19:59















You have multiple forms. Just wrap the textareas in one form with one submit button.

– AbraCadaver
Nov 19 '18 at 19:59





You have multiple forms. Just wrap the textareas in one form with one submit button.

– AbraCadaver
Nov 19 '18 at 19:59












2 Answers
2






active

oldest

votes


















0














You can try something like this:






<form>

<table>
<tr>
<td>project 1</td>
<td></td>
<td><input name="projects[1][comment]"></td>
<td><button name="submit_id" value="1">Comment</button></td>
</tr>
<tr>
<td>project 2</td>
<td></td>
<td><input name="projects[2][comment]"></td>
<td><button name="submit_id" value="2">Comment</button></td>
</tr>
<table>
<button name="submit_id" value="all">Submit all</button>

</form>





Any submit button inside <form> will send whole form to the server, but using submit_id value you can make decision which fields you need to process with this request: comment of one particular project, or all comments.



Project 2 button:



Button for project 2



«Submit all» button:



Submit all button






share|improve this answer

































    0














    Write a javascript code to get all the values from the input. Add a class to the inputs like 'planets' and get them all by the javascript code
    $('.planets')
    and then iterate over the planets read the values to an array and send that to server.



    $(function(){

    $('#sender').on("click", function(){

    var pl = $(".planets");
    var data = ;
    pl.each(function(){
    data.push($(this).val());
    });

    serverData = JSON.stringify(data)

    document.writeln(serverData)

    });

    });


    pass serverData to server using ajax and do json decode to convert back to array and use it to store wherever you want.






    share|improve this answer























      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%2f53381656%2fone-submit-button-for-several-textarea-fields-php-html%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can try something like this:






      <form>

      <table>
      <tr>
      <td>project 1</td>
      <td></td>
      <td><input name="projects[1][comment]"></td>
      <td><button name="submit_id" value="1">Comment</button></td>
      </tr>
      <tr>
      <td>project 2</td>
      <td></td>
      <td><input name="projects[2][comment]"></td>
      <td><button name="submit_id" value="2">Comment</button></td>
      </tr>
      <table>
      <button name="submit_id" value="all">Submit all</button>

      </form>





      Any submit button inside <form> will send whole form to the server, but using submit_id value you can make decision which fields you need to process with this request: comment of one particular project, or all comments.



      Project 2 button:



      Button for project 2



      «Submit all» button:



      Submit all button






      share|improve this answer






























        0














        You can try something like this:






        <form>

        <table>
        <tr>
        <td>project 1</td>
        <td></td>
        <td><input name="projects[1][comment]"></td>
        <td><button name="submit_id" value="1">Comment</button></td>
        </tr>
        <tr>
        <td>project 2</td>
        <td></td>
        <td><input name="projects[2][comment]"></td>
        <td><button name="submit_id" value="2">Comment</button></td>
        </tr>
        <table>
        <button name="submit_id" value="all">Submit all</button>

        </form>





        Any submit button inside <form> will send whole form to the server, but using submit_id value you can make decision which fields you need to process with this request: comment of one particular project, or all comments.



        Project 2 button:



        Button for project 2



        «Submit all» button:



        Submit all button






        share|improve this answer




























          0












          0








          0







          You can try something like this:






          <form>

          <table>
          <tr>
          <td>project 1</td>
          <td></td>
          <td><input name="projects[1][comment]"></td>
          <td><button name="submit_id" value="1">Comment</button></td>
          </tr>
          <tr>
          <td>project 2</td>
          <td></td>
          <td><input name="projects[2][comment]"></td>
          <td><button name="submit_id" value="2">Comment</button></td>
          </tr>
          <table>
          <button name="submit_id" value="all">Submit all</button>

          </form>





          Any submit button inside <form> will send whole form to the server, but using submit_id value you can make decision which fields you need to process with this request: comment of one particular project, or all comments.



          Project 2 button:



          Button for project 2



          «Submit all» button:



          Submit all button






          share|improve this answer















          You can try something like this:






          <form>

          <table>
          <tr>
          <td>project 1</td>
          <td></td>
          <td><input name="projects[1][comment]"></td>
          <td><button name="submit_id" value="1">Comment</button></td>
          </tr>
          <tr>
          <td>project 2</td>
          <td></td>
          <td><input name="projects[2][comment]"></td>
          <td><button name="submit_id" value="2">Comment</button></td>
          </tr>
          <table>
          <button name="submit_id" value="all">Submit all</button>

          </form>





          Any submit button inside <form> will send whole form to the server, but using submit_id value you can make decision which fields you need to process with this request: comment of one particular project, or all comments.



          Project 2 button:



          Button for project 2



          «Submit all» button:



          Submit all button






          <form>

          <table>
          <tr>
          <td>project 1</td>
          <td></td>
          <td><input name="projects[1][comment]"></td>
          <td><button name="submit_id" value="1">Comment</button></td>
          </tr>
          <tr>
          <td>project 2</td>
          <td></td>
          <td><input name="projects[2][comment]"></td>
          <td><button name="submit_id" value="2">Comment</button></td>
          </tr>
          <table>
          <button name="submit_id" value="all">Submit all</button>

          </form>





          <form>

          <table>
          <tr>
          <td>project 1</td>
          <td></td>
          <td><input name="projects[1][comment]"></td>
          <td><button name="submit_id" value="1">Comment</button></td>
          </tr>
          <tr>
          <td>project 2</td>
          <td></td>
          <td><input name="projects[2][comment]"></td>
          <td><button name="submit_id" value="2">Comment</button></td>
          </tr>
          <table>
          <button name="submit_id" value="all">Submit all</button>

          </form>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 '18 at 20:28

























          answered Nov 19 '18 at 20:20









          StormStorm

          8419




          8419

























              0














              Write a javascript code to get all the values from the input. Add a class to the inputs like 'planets' and get them all by the javascript code
              $('.planets')
              and then iterate over the planets read the values to an array and send that to server.



              $(function(){

              $('#sender').on("click", function(){

              var pl = $(".planets");
              var data = ;
              pl.each(function(){
              data.push($(this).val());
              });

              serverData = JSON.stringify(data)

              document.writeln(serverData)

              });

              });


              pass serverData to server using ajax and do json decode to convert back to array and use it to store wherever you want.






              share|improve this answer




























                0














                Write a javascript code to get all the values from the input. Add a class to the inputs like 'planets' and get them all by the javascript code
                $('.planets')
                and then iterate over the planets read the values to an array and send that to server.



                $(function(){

                $('#sender').on("click", function(){

                var pl = $(".planets");
                var data = ;
                pl.each(function(){
                data.push($(this).val());
                });

                serverData = JSON.stringify(data)

                document.writeln(serverData)

                });

                });


                pass serverData to server using ajax and do json decode to convert back to array and use it to store wherever you want.






                share|improve this answer


























                  0












                  0








                  0







                  Write a javascript code to get all the values from the input. Add a class to the inputs like 'planets' and get them all by the javascript code
                  $('.planets')
                  and then iterate over the planets read the values to an array and send that to server.



                  $(function(){

                  $('#sender').on("click", function(){

                  var pl = $(".planets");
                  var data = ;
                  pl.each(function(){
                  data.push($(this).val());
                  });

                  serverData = JSON.stringify(data)

                  document.writeln(serverData)

                  });

                  });


                  pass serverData to server using ajax and do json decode to convert back to array and use it to store wherever you want.






                  share|improve this answer













                  Write a javascript code to get all the values from the input. Add a class to the inputs like 'planets' and get them all by the javascript code
                  $('.planets')
                  and then iterate over the planets read the values to an array and send that to server.



                  $(function(){

                  $('#sender').on("click", function(){

                  var pl = $(".planets");
                  var data = ;
                  pl.each(function(){
                  data.push($(this).val());
                  });

                  serverData = JSON.stringify(data)

                  document.writeln(serverData)

                  });

                  });


                  pass serverData to server using ajax and do json decode to convert back to array and use it to store wherever you want.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 '18 at 21:55









                  Azharuddin LaskarAzharuddin Laskar

                  122




                  122






























                      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%2f53381656%2fone-submit-button-for-several-textarea-fields-php-html%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

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents