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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:48:47+00:00 2026-05-31T05:48:47+00:00

This has driven me really bananas. It’s so simple and easy and yet I

  • 0

This has driven me really bananas. It’s so simple and easy and yet I can’t figure out what’s wrong with it.

I want to get my checkbox value populated in my controller (for testing purposes).

Here is my form.

<a href='#' name='submitForm'>submit the form</a>   
//I have jquery attached to this tag and will submit the form when user clicks it

echo form_open('test/show');

echo form_checkbox('checkbox[]','value1');
echo form_checkbox('checkbox[]','value2');
echo form_checkbox('checkbox[]','value3');
echo form_checkbox('checkbox[]','value4');

echo "<input type='text' name='text1' value='ddd'>";

echo form_close();


//My controller test

public function show(){

$data1=$this->input->post('text1');  
//I can get text1 value from input box

$data2=$this->input->post('checkbox');  
//it keeps giving me undefined index 'checkbox'

$data3=$_POST['checkbox'];
//same error message
//WTH is going on here!!!!!

}

Please help. This thing drives me nuts! Thanks.

UPDATE:
Thanks for the help. To be more precisely, my submit button is a <a> tag and outside of form tag. It appear that I have to include <a> tag inside my form tag to make them works. Is that true?

  • 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-31T05:48:48+00:00Added an answer on May 31, 2026 at 5:48 am

    A checkbox will not submit any data if it is unchecked as they’re not considered successful (as per the w3c specification here)

    If you actually tick the box and submit, it’ll work – in fact it does, I’ve just tested it.

    You need to wrap calls to $_POST in the isset() function.

    if( isset( $_POST['checkbox'] ) ) {}
    

    Calling $this->input->post('checkbox') shouldn’t give you an undefined index error as the method deals with this eventuality. the Input::post() method returns false or the value of the checkbox.

    Edit —

    In response to your amendment to your question, you must use an element of type input with the type attribute set to submit in order to submit your form data without the use of Javascript etc. This button must be INSIDE the <form></form> which you are intending to submit.

    <input type="submit" value="Submit">
    

    The type="submit" causes the browser to send the data as submit event occurs. If you wish to use another element insider or outside of the form to do this you need to use Javascript. This however can be disabled on a per browser/user basis and isn’t reliable as a result.

    // Standard Javascript
    <form name="myform"...
    <a onclick="javascript:document.myform.submit();" href="javascript:void(0)">Submit</a>
    
    // jQuery
    $('#my-a-tag-submit-button').live( 'click', function() {
        $('#my-form').submit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been a problem that I haven't been able to figure out for
This has got to be something simple: I set up a frames page with
I've been doing some reading on Domain Driven Development but can't see how this
the way to call a method has driven me really crazy! and unfortunately I
While this question has been asked in a variety of contexts before, I can't
This is probably a really easy question to answer, but for some reason I'm
This thing has given me a really bad headache. I'm trying to load a
I have a C++ driver I'm trying to compile, and it has this line
This has been an adventure. I started with the looping duplicate query located in
This has been driving me crazy for a few days. Why doesn't the following

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.