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

  • Home
  • SEARCH
  • 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 7636519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:42:08+00:00 2026-05-31T07:42:08+00:00

I have a form which contains list of data, I added a checkbox in

  • 0

I have a form which contains list of data, I added a checkbox in from of each, when I click on the uppermost checkbox it selects all. But if I have just one row of data and I click on the upper most checkboxes dont work. Here is the script below.

////checking all checkbox on page
function checkAll(field)
{
   // alert(field.length);
    for (i = 0; i < field.length; i++){
        field[i].checked = true ;
    }
}

////unchecking all checkbox on page
function uncheckAll(field)
{
    for (i = 0; i < field.length; i++){
        field[i].checked = false;
    }
}
function selectCHK(e){
    if(e.checked==true){
        //alert("Yeah");
        checkAll(document.paginate_list.list);                                  
    }else{
        uncheckAll(document.paginate_list.list);

    }                               
}

function ApplyToSelected(){
var SelectedVal="";
var withSelected=document.getElementById("withSelected");
//
if(withSelected.value==1){

  //if(document.getElementById("list")){

  //    SelectedVal=document.getElementById("list").value;

  //}
for(i=0; i<document.paginate_list.list.length;i++){
      if (document.paginate_list.list[i].checked) {
          //alert(i);
          SelectedVal +=document.paginate_list.list[i].value+",";

      }
  }

      if(SelectedVal==""){
          return false;
      }

  if(confirm("Are you Sure you want to Delete the Selected Row?")){
      $.ajax({
          url: "../__lib__/pagingLib.php?tableDeleteID="+SelectedVal,
          context: document.body,
          success: function(response,status,xhr){
           if(response==1){
              alert("Deleted Successfully"); 
              window.location.reload();
           }else{
               alert(response);
               alert("An Error Occurred while Deleting, Please Try Again!");
           }
          // alert(response);
            }
       });
  }

}
}

HTML DATA

<form name="paginate_list" style="display:inline;" action="" method="post">
<table  class="PagingBody">
<tr>
<th><input type=checkbox   onclick=selectCHK(this)  ></th>
<th>Category Title</th><th>Actions</th>
</tr>
<tr class="even">
<td><input   name=list[]   type=checkbox  id=list   value=10></td>
<td>Web Design</td>
<td><a href=?page=cat&edit=10>Edit</a> | <a href=#10>Delete</a></td>
<tr/>
</table>

<table>
<tr>
<td>
<select name="withSelected" id="withSelected">  
<option value="0">With Selected</option>
<option value="1">Delete</option>
</select>

<input type="button" name="applyToSelected" id="applyToSelected" value="Apply to Selected" onclick="ApplyToSelected()" />
</td>
<tr/>
</table>
</form>

paginate_list.list represents the name of my form and the list name.

  • 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-31T07:42:10+00:00Added an answer on May 31, 2026 at 7:42 am

    This fiddle will demonstrate what’s happening

    FIDDLE HERE

    The reason why this is happening is because the browser generates a NodeList when you have more than one element in the list that you send to the function checkAll();
    Otherwise you just get the normal input element.

    I added an instanceof check to see what type of object it was.

    To check for this in IE follow this thread here on SO:
    NodeList check in IE

    Good luck!

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

Sidebar

Related Questions

I have a form which contains some rows, each has a checkbox in the
Basically I have an InfoPath form which recieves some data from a SharePoint list,
I have a WPF form which contains 30x30 grid where each grid cell is
I have created one jsp form which contains the username textfield. On the click
I have a table which contains TV Guide data. In a simplified form, the
I have a form which contains a whole heap of data entry fields that
I have a view which contains a form, the form posts and the data
I have a form which contains a lot of elements, my DB guy has
i have a registration form which contains a postalcode and a country drop down
I have a php file that contains a form (which contains 2 input boxes

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.