Answers.Body: <p>This question is not really Craft related. Since you just don't send a valid request. You can't send one key multiple times unless you do it in an array.</p>
  
  <p>The php <code>$_GET</code> is a simple array with all your values and you overwrite them again and again. </p>
  
  <p><a href="https://stackoverflow.com/questions/5098397/how-to-pass-an-array-in-get-in-php">https://stackoverflow.com/questions/5098397/how-to-pass-an-array-in-get-in-php</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-14T00:32:28.957Z
Answers.Text: Please see edits to original post.
Answers.UserDisplayName: Philip Jones
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-13T23:29:06.190Z
Answers.LastActivityDate: 2017-12-13T23:29:06.190Z
Answers.UserDisplayName: Robin Schambach
Answers.Body: <p>Using the corrected checkbox name <code>name=checkValue[]</code> the submitted values</p>
  
  <p><code>?checkValue%5B%5D=12345&amp;checkValue%5B%5D=23456&amp;checkValue%5B%5D=34567</code></p>
  
  <p>are converted to an array. The array values can now be accessed using</p>
  
  <pre><code>{% set checkVals = craft.request.getQuery('checkValue') %}
  
  {{ checkVals[1] }} {# outputs 23456 #}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{% for cVal in checkVals %}
      {{ cVal }}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-14T04:15:48.453Z
Answers.LastActivityDate: 2017-12-14T04:15:48.453Z
Answers.UserDisplayName: Philip Jones
Body: <p>I have a URL passing values from form checkboxes to a template. All the checkboxes are grouped with the same <code>name=</code> attribute. When multiple checkboxes are selected, the query string looks something like:</p>
  
  <p><code>?checkValue=12345&amp;checkValue=23456&amp;checkValue=34567</code></p>
  
  <p>However, <code>craft.request.getQuery('checkValue')</code> returns only the last value (34567 in this case).</p>
  
  <p>How can I retrieve all the values so they can be used and manipulated?</p>
  
  <p>EDIT: I've corrected the naming of the checkboxes from <code>name="checkValue"</code> to <code>name="checkValue[]"</code>, so now my query string looks like this:</p>
  
  <p><code>?checkValue%5B%5D=12345&amp;checkValue%5B%5D=23456&amp;checkValue%5B%5D=34567</code></p>
  
  <p>Does that change what can be accessed using <code>craft.request.getQuery('checkValue')</code>?</p>
  
Tags: <checkboxes><querystring>
Title: getQuery() returns only one value
ThreadText: # getQuery() returns only one value
  
  (Asked by: username_0 on 2017-12-13)
  
  I have a URL passing values from form checkboxes to a template. All the checkboxes are grouped with the same `name=` attribute. When multiple checkboxes are selected, the query string looks something like:
  
  `?checkValue=12345&checkValue=23456&checkValue=34567`
  
  However, `craft.request.getQuery('checkValue')` returns only the last value (34567 in this case).
  
  How can I retrieve all the values so they can be used and manipulated?
  
  EDIT: I've corrected the naming of the checkboxes from `name="checkValue"` to `name="checkValue[]"`, so now my query string looks like this:
  
  `?checkValue%5B%5D=12345&checkValue%5B%5D=23456&checkValue%5B%5D=34567`
  
  Does that change what can be accessed using `craft.request.getQuery('checkValue')`?
  
  **Tags:** checkboxes, querystring
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-12-13. Score: 3 | Accepted answer
  
  This question is not really Craft related. Since you just don't send a valid request. You can't send one key multiple times unless you do it in an array.
  
  The php `$_GET` is a simple array with all your values and you overwrite them again and again.
  
  <https://stackoverflow.com/questions/5098397/how-to-pass-an-array-in-get-in-php>
  
  > **Comments:**
  > **username_0**: Please see edits to original post.  
  
  ---
  
  ### Answer by username_0 on 2017-12-14. Score: 2
  
  Using the corrected checkbox name `name=checkValue[]` the submitted values
  
  `?checkValue%5B%5D=12345&checkValue%5B%5D=23456&checkValue%5B%5D=34567`
  
  are converted to an array. The array values can now be accessed using
  
  ```
  {% set checkVals = craft.request.getQuery('checkValue') %}
  
  {{ checkVals[1] }} {# outputs 23456 #}
  
  ```
  
  or
  
  ```
  {% for cVal in checkVals %}
      {{ cVal }}
  {% endfor %}
  
  ```
  
  
  ---
  
  