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 7986719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:56:05+00:00 2026-06-04T11:56:05+00:00

I have a checkbox coded in HTML, so far everything works, however I need

  • 0

I have a checkbox coded in HTML, so far everything works, however I need to pass in an array in the name attribute of the checkboxes. I know its easy enough to do when you pass a variable into the name attribute. But for arrays it is proving tricker.

Here is my code:

   <?php // spit out rest of the list
       $permiCheck = array();
       foreach($pList as $value){
        //go into array, get what is needed to pass into the name attribute
        echo '<tr>';

        echo '<td>';
        echo $value['PName'];
        echo '</td>';
        //pass an array in
        $permiCheck['Id'] = $value['Id'];
        $permiCheck['ItemId'] = $value['ItemId'];
        if($value['Id']!=null) {



        ?>
        <td style="text-align:center;"> <input type="checkbox" checked="yes" name="<?php $permiCheck;?>" value="" id="change"></td>

After I have done this I intend to retrieve what was in the array via the POST method for form validation.

Any idea how I can do that, many thanks.

  • 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-06-04T11:56:06+00:00Added an answer on June 4, 2026 at 11:56 am

    The name of the checkbox element has to be a string, you can however use checkboxes as an array.
    i.e.

    <input type="checkbox" name="checkboxName[]" value="1"/>
    <input type="checkbox" name="checkboxName[]" value="2"/>
    

    will return

    var_dump($_POST)
    
    array
      'checkboxName' => 
        array
          0 => int 1
          1 => int 2
    

    I’m not sure what you’re trying to do, but maybe you could do it this way

    <td style="text-align:center;">
        <input type="checkbox" checked="yes" name="<?=$permiCheck['ItemId']?>[]" value="<?=$permiCheck['Id']?>" id="change">
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
In normal html, we could have an array field like person[] <input name=person[] type=text
I have the following HTML code: <div class=member> <input type=checkbox value=64 style=display:none; name=memberId[] />
jsFiddle: http://jsfiddle.net/KUcrm/ I have this code: HTML <input id=Check1 type=checkbox name=ckbRG tabindex=1 checked /><label
I have some HTML code like this: <input id=fieldname-1 name=field_name[value][1] value=1 type=checkbox /> <input
I have several like this in my HTML code: <input class=table type=checkbox name=interest[] value=finger
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I need to have a checkbox which ajax-submits a form. The following code throws
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();

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.