Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 702305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:42:21+00:00 2026-05-14T03:42:21+00:00

I have a series of checkbox inputs and corresponding text area inputs to allow

  • 0

I have a series of checkbox inputs and corresponding text area inputs to allow specification of quantity.

Here’s what the two fields look like when the item is static (i.e. only 1):

<input type="checkbox" name="measure[checked][]" value="<?=$item->id?>">
<input type="hidden" name="measure[quantity][]" value="1" />

Here’s what the input fields look like for all items that have a specifiable quantity:

<input type="checkbox" name="measure[checked][]" value="<?=$item->id?>"> 
<input class="item_mult" value="0" type="text" name="measure[quantity][]" />

This would play nicely, if within the array, it didn’t output like this, after collecting it with:

$field = $this->input->post('measure',true);

Array ( 

     [quantity] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 25 [7] => 0 [8] => 0 [9] => 0 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [14] => 1 [15] => 1 [16] => 1 [17] => 1 [18] => 1 [19] => 1 [20] => 1 [21] => 1 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => 0 [30] => 0 [31] => 0 [32] => 0 [33] => 0 [34] => 0 [35] => 0 [36] => 0 [37] => 0 [38] => 0 [39] => 0 [40] => 0 [41] => 1 [42] => 1 [43] => 1 [44] => 1 [45] => 1 [46] => 1 [47] => 1 [48] => 1 [49] => 1 [50] => 1 [51] => 1 [52] => 0 [53] => 0 [54] => 0 ) 

     [checked] => Array ( [0] => 4 [1] => 6 [2] => 13 ) 

) 

I understand what the values in the checked array are, I just do not understand how to relate the first field to the second, later in the program.

How do I incorporate the correct code to relate checked items to quantities?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:42:22+00:00Added an answer on May 14, 2026 at 3:42 am

    Use something common (the item id) to relate them:

    <input type="checkbox" name="measure[checked][<?=$item->id?>]" value="1"> 
    <input class="item_mult" value="0" type="text" name="measure[quantity][<?=$item->id?>]" />
    

    Now you’ll know what measures relate to what items. However, a better way would be:

    <input type="checkbox" name="measure[<?=$item->id?>][checked]" value="1"> 
    <input class="item_mult" value="0" type="text" name="measure[<?=$item->id?>][quantity]" />
    

    Here you have an array (measure) of items, with two ‘properties’: ‘checked’ and ‘quantity’. Easy to iterate over and understand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website with a series of empty text fields that the user
I have a series of checkboxes and I would like to append the text
I have a scenario where I want to toggle series based on checkbox selection.
I have a series of PHP page, and I would like to use conditional
I have a series of if statements in a function like this: if time
Currently I have a webform that has a series of links. What I'd like
I'm coding this plugin that validates if a series of checkbox groups have at
I have a series of divs in two columns with some javascript dictating some
I have a series of LI inside a UL like this: <ul> <li class=section
on submit, i need to collect the values for a series of checkbox fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.