How do I send search parameters to Flask server?












0














This is my first question! I am trying to enter a search term into a search box, and when I click Submit, I want the search term inserted into this URL:



http://www.hadrians-search.tk/search?search_param=mario?&items_per_page=2&page_number=2


mario would be the search term. This is the search page I am testing with:



http://cs.oswego.edu/~jmcquaid/CSC-380/search3.html


When I enter a search term such as ball into the search box and click Submit, this is the URL I get:



http://hadrians-search.tk/search?search%3Fsearch_param%3D=ball


As you can see, this is clearly not the URL I am intending to get.



Bear in mind that search3.html is just a file I am testing with on the front-end:



<!DOCTYPE html>
<html>
<body>

<form id="myForm" action="http://hadrians-search.tk/search?search_param=">
Search: <input type="text" name="search?search_param="><br><br>
<input type="button" onclick="myFunction()" value="Submit form">
</form>

<script>
function myFunction() {
document.getElementById("myForm").submit().action="http://hadrians-search.tk/search?search_param=";
}
</script>

</body>
</html>


So basically I am trying to send the search term entered in the search box to the Flask server, but it isn't getting sent properly. Should I be trying an HTTP GET Request? I originally tried this, but I couldn't figure out how to integrate an HTTP GET Request with a search box and button. Because of this, I instead tried to use action, as you can see in the file. Any advice that you can provide will be greatly appreciated, and I thank you for your time.










share|improve this question



























    0














    This is my first question! I am trying to enter a search term into a search box, and when I click Submit, I want the search term inserted into this URL:



    http://www.hadrians-search.tk/search?search_param=mario?&items_per_page=2&page_number=2


    mario would be the search term. This is the search page I am testing with:



    http://cs.oswego.edu/~jmcquaid/CSC-380/search3.html


    When I enter a search term such as ball into the search box and click Submit, this is the URL I get:



    http://hadrians-search.tk/search?search%3Fsearch_param%3D=ball


    As you can see, this is clearly not the URL I am intending to get.



    Bear in mind that search3.html is just a file I am testing with on the front-end:



    <!DOCTYPE html>
    <html>
    <body>

    <form id="myForm" action="http://hadrians-search.tk/search?search_param=">
    Search: <input type="text" name="search?search_param="><br><br>
    <input type="button" onclick="myFunction()" value="Submit form">
    </form>

    <script>
    function myFunction() {
    document.getElementById("myForm").submit().action="http://hadrians-search.tk/search?search_param=";
    }
    </script>

    </body>
    </html>


    So basically I am trying to send the search term entered in the search box to the Flask server, but it isn't getting sent properly. Should I be trying an HTTP GET Request? I originally tried this, but I couldn't figure out how to integrate an HTTP GET Request with a search box and button. Because of this, I instead tried to use action, as you can see in the file. Any advice that you can provide will be greatly appreciated, and I thank you for your time.










    share|improve this question

























      0












      0








      0







      This is my first question! I am trying to enter a search term into a search box, and when I click Submit, I want the search term inserted into this URL:



      http://www.hadrians-search.tk/search?search_param=mario?&items_per_page=2&page_number=2


      mario would be the search term. This is the search page I am testing with:



      http://cs.oswego.edu/~jmcquaid/CSC-380/search3.html


      When I enter a search term such as ball into the search box and click Submit, this is the URL I get:



      http://hadrians-search.tk/search?search%3Fsearch_param%3D=ball


      As you can see, this is clearly not the URL I am intending to get.



      Bear in mind that search3.html is just a file I am testing with on the front-end:



      <!DOCTYPE html>
      <html>
      <body>

      <form id="myForm" action="http://hadrians-search.tk/search?search_param=">
      Search: <input type="text" name="search?search_param="><br><br>
      <input type="button" onclick="myFunction()" value="Submit form">
      </form>

      <script>
      function myFunction() {
      document.getElementById("myForm").submit().action="http://hadrians-search.tk/search?search_param=";
      }
      </script>

      </body>
      </html>


      So basically I am trying to send the search term entered in the search box to the Flask server, but it isn't getting sent properly. Should I be trying an HTTP GET Request? I originally tried this, but I couldn't figure out how to integrate an HTTP GET Request with a search box and button. Because of this, I instead tried to use action, as you can see in the file. Any advice that you can provide will be greatly appreciated, and I thank you for your time.










      share|improve this question













      This is my first question! I am trying to enter a search term into a search box, and when I click Submit, I want the search term inserted into this URL:



      http://www.hadrians-search.tk/search?search_param=mario?&items_per_page=2&page_number=2


      mario would be the search term. This is the search page I am testing with:



      http://cs.oswego.edu/~jmcquaid/CSC-380/search3.html


      When I enter a search term such as ball into the search box and click Submit, this is the URL I get:



      http://hadrians-search.tk/search?search%3Fsearch_param%3D=ball


      As you can see, this is clearly not the URL I am intending to get.



      Bear in mind that search3.html is just a file I am testing with on the front-end:



      <!DOCTYPE html>
      <html>
      <body>

      <form id="myForm" action="http://hadrians-search.tk/search?search_param=">
      Search: <input type="text" name="search?search_param="><br><br>
      <input type="button" onclick="myFunction()" value="Submit form">
      </form>

      <script>
      function myFunction() {
      document.getElementById("myForm").submit().action="http://hadrians-search.tk/search?search_param=";
      }
      </script>

      </body>
      </html>


      So basically I am trying to send the search term entered in the search box to the Flask server, but it isn't getting sent properly. Should I be trying an HTTP GET Request? I originally tried this, but I couldn't figure out how to integrate an HTTP GET Request with a search box and button. Because of this, I instead tried to use action, as you can see in the file. Any advice that you can provide will be greatly appreciated, and I thank you for your time.







      javascript html flask get web-frontend






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 13:26









      jtetra13

      14




      14
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You can pass the parameters via GET. If you have three parameters, you could add the three elements in the form. You can do something like this.






          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>








          share|improve this answer





















          • In the snippet doesn't work due to the https...
            – manelseo
            Nov 19 '18 at 14:16










          • Thanks! This worked for me.
            – jtetra13
            Nov 23 '18 at 20:06











          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%2f53375648%2fhow-do-i-send-search-parameters-to-flask-server%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can pass the parameters via GET. If you have three parameters, you could add the three elements in the form. You can do something like this.






          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>








          share|improve this answer





















          • In the snippet doesn't work due to the https...
            – manelseo
            Nov 19 '18 at 14:16










          • Thanks! This worked for me.
            – jtetra13
            Nov 23 '18 at 20:06
















          0














          You can pass the parameters via GET. If you have three parameters, you could add the three elements in the form. You can do something like this.






          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>








          share|improve this answer





















          • In the snippet doesn't work due to the https...
            – manelseo
            Nov 19 '18 at 14:16










          • Thanks! This worked for me.
            – jtetra13
            Nov 23 '18 at 20:06














          0












          0








          0






          You can pass the parameters via GET. If you have three parameters, you could add the three elements in the form. You can do something like this.






          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>








          share|improve this answer












          You can pass the parameters via GET. If you have three parameters, you could add the three elements in the form. You can do something like this.






          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>








          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>





          <!DOCTYPE html>
          <html>

          <body>
          <form id="myForm" method="get"
          action="http://hadrians-search.tk/search">
          search_param: <input type="text" name="search_param"><br><br>
          items_per_page: <input type="text" name="items_per_page"><br><br>
          page_number: <input type="text" name="page_number"><br><br>
          <input value="Submit form" type="submit">
          </form>
          </body>
          </html>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 14:07









          manelseo

          1124




          1124












          • In the snippet doesn't work due to the https...
            – manelseo
            Nov 19 '18 at 14:16










          • Thanks! This worked for me.
            – jtetra13
            Nov 23 '18 at 20:06


















          • In the snippet doesn't work due to the https...
            – manelseo
            Nov 19 '18 at 14:16










          • Thanks! This worked for me.
            – jtetra13
            Nov 23 '18 at 20:06
















          In the snippet doesn't work due to the https...
          – manelseo
          Nov 19 '18 at 14:16




          In the snippet doesn't work due to the https...
          – manelseo
          Nov 19 '18 at 14:16












          Thanks! This worked for me.
          – jtetra13
          Nov 23 '18 at 20:06




          Thanks! This worked for me.
          – jtetra13
          Nov 23 '18 at 20:06


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53375648%2fhow-do-i-send-search-parameters-to-flask-server%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

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory