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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:25:57+00:00 2026-05-31T19:25:57+00:00

This is my script: HTML Code: <script> function pickIt(pId){ if(document.getElementById(pId).checked==true){ document.getElementById(pId).checked=false; }else{ document.getElementById(pId).checked =

  • 0

This is my script:

HTML Code:

<script>
function pickIt(pId){
    if(document.getElementById(pId).checked==true){
        document.getElementById(pId).checked=false;
    }else{
        document.getElementById(pId).checked = true;
    }
    submitForm();
    return true;
}
</script>
<img src="images/bagua-square.gif" border="0" usemap="#Map2" />
<map name="Map2" id="Map2">
    <area shape="rect" coords="201,14,284,100" onclick="pickIt(1);" />
    <area shape="rect" coords="202,104,284,190" onclick="pickIt(2);" />
    <area shape="rect" coords="202,195,284,283" onclick="pickIt(3);" />
</map>
<div style="display:none;">
    <input type="checkbox" id="1" name="box[]" />
    <input type="checkbox" id="2" name="box[]" />
    <input type="checkbox" id="3" name="box[]" />
</div>

PHP Code:

<?php
    print_r($_POST['box']);
?>

When I click on box id 1 pickIt() function turn checkbox 1 to on. And the php shows array(0=>’on’)

But I also want to get checkbox value which are not checked such that php will show
array(0=>’on’, 1=>’off’, 2=>’off’)

Actually i want to get all checkboxes with their status on and off because i am using these id in mysql db to update record status on or off.
please guide.

  • 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-31T19:25:58+00:00Added an answer on May 31, 2026 at 7:25 pm

    Checkboxes send their value if they are checked and are not sent at all if they are not.

    You should have:

    <input type="checkbox" id="1" name="box[]" value="1" />
    <input type="checkbox" id="2" name="box[]" value="2"  />
    <input type="checkbox" id="3" name="box[]" value="3"  />
    

    So the values will be 1, 2 and 3 instead of on, on and on. Then you can tell which ones are checked as they won’t all be the same.

    If you really want your data structure to be array(0=>'on', 1=>'off', 2=>'off') then you could do:

    $foo = array();
    for ($i = 1; $i <= 3; $i++) {
        $foo[$i] = in_array($i, $_GET['box']) ? 'on' : 'off';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {
I have this code: <span id=Santiago4>Santiago</span> <br>more html code here<br> <span id=Santiago4>Santiago</span> <script> jQuery(#Santiago4).click(function()
Hello friends here's my code function dropItems(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('dropContent').innerHTML; if(html.length<=0){ html.innerHTML='<img
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
Given this markup: // Calendar.html?date=1/2/2003 <script> $(function() { $('.inlinedatepicker').datepicker(); }); </script> ... <div class=inlinedatepicker
This script works perfectly in all the browsers, except Google Chrome. $(document).ready(function(){ $(.banners-anim img).each(function(){
I have html code like this <telerik:RadButton ID=rdYes runat=server AutoPostBack=False ButtonType=ToggleButton CssClass=rdYes Text= ToggleType=Radio
I have following code (html,js,jquery) snippet ( http://jsfiddle.net/MUScJ/2/ ): <script type=text/javascript> function someFunc(){ html
Hello guys on my blog I use this script: jQuery(document).ready(function () { jQuery(.postbox).hover(function ()

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.