Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
How to add parameter in the html form action?

I have a form like this:

<form action="studyresults.show" method="POST">
   ...
   ...
   <div style="clear: both;float: right;padding-top: 15px;padding-bottom:5px;">
          <input id="submitButton" style="float:right;margin-top:-80px;" type="submit" class="btn btn-primary" value="Add" />
        </div>

I want to add a parameter from url string like this:

<script>
function getQueryStringValue (key) {
          return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
        }
</script>

I would like to query the url with "token" string so I can pass "token" as part of POST request parameter when I click submit button. How can I achieve this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since you're using JSP, there's no need to involve JavaScript here. You can pull any query string parameter value directly using JSP's EL expression language.

<form action="studyresults.show" method="POST">
    <input type="hidden" name="token" value="${param.token}" />
    ...
    <div style="clear: both;float: right;padding-top: 15px;padding-bottom:5px;">
        <input id="submitButton" style="float:right;margin-top:-80px;"
               type="submit" class="btn btn-primary" value="Add" />
    </div>
</form>

The above example adds the token value ${param.token} as a hidden <input> field which will get POSTed along with other field values when the form is submitted.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!