• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

check all checkboxes

Hello Experts,
I am using the attached script to post ajax data to the server, the user has an option to select records they want to process by ticking the checkbox, i am assuming that if the user did not tick any checkboxes then process all the records available on the page.
in order to do this, i am ticking the checkboxes from the script so that i can post appropriate records ids.
this is actually visible on the page, soon you click on save button user can see the checkboxes being ticked and posted.
i wonder if i can do the same without actually making the check boxes tick visible?
many thanks for your help
regards
sam
0
newbie27
Asked:
newbie27
  • 4
  • 4
2 Solutions
 
newbie27Author Commented:
hope you understand what I have tried to say you here?
thanks for help and time...


function addToList()
{
  if($("#drpLists").val() == 0){
    alert('Please select a list');  
  } 
	
    var result = "";             
    $(".chkRefNos").each( function () 
        {
        if(this.checked == true) {     
             result += "," + $(this).val()  ;
        }
        });
        result = result.substr(1);
            if( result ){
				
										  submitForm('frmList', 'savefields');
					//} 
            } else{
				checkAll("on"); // this is making the tick visible...
				submitForm('frmList', 'savefields'); 	
			} 
  }
 //return false;   
} 
 
 
function checkAll(chkd)
{
$(".chkRefNos").each(function(){
                this.checked = chkd;
            });
}
  

Open in new window

0
 
Airyck666Commented:
I know this isn't what you are asking but maybe it would be better to have them all checked by default.  This way is clearer to the user that they will all be processed without any action on their part.
0
 
hieloCommented:
>>i am assuming that if the user did not tick any checkboxes then process all the records available on the page
In my opinion, that is just a bad decision. Look at it from the user's perspective. "I did not check anything, why is it processing everything?". Other than the fact that it is counter intuitive, your approach will just lead to complaints.
Having said that, you may choose to check only the check all box (and not check the others), so on the server you will only see one checkbox. The drawback is that if the other checkboxes are not actually checked then you will not receive the ids of those checkboxes. What you are trying to do is just a recipe for a major headache.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
newbie27Author Commented:
Hello Hielo,
Many thanks for your suggestion. I actually have had this "checkAll" check box in the first place, and  a validation before posting the records to save it on the server, either to check any or all as an alert to the user.
But then I was been told to remove  the validation and assume that if the user did not chose to tick any of the check boxes on the page then his intentions are to add all the records, hence I was actually forcing these check boxes to get checked by  checkAll(chkd).

If you still think it is wrong to do this way, then I will let them know and force the user to tick before posting.

thanks for your help/advice
regards
sam

0
 
hieloCommented:
>>If you still think it is wrong to do this way
I'm not saying that it is "wrong" in the strict sense of the word. It is counter-intuitive. But since you were told

" told to remove  the validation and assume that if the user did not chose to tick any of the check boxes on the page then his intentions are to add all the records"

then I guess you will just have to comply with the request. The best you can do is explain the counter-intuitiveness of that approach. Having said that, then you don't need any checkall button at all, since you will be assuming that everything is checked.
0
 
newbie27Author Commented:
thanks hielo,

--> then you don't need any checkall button at all,
ok fine i will remove the checkall button..

please let me know , if its correct to have it like is then?

  checkAll("on"); // this will actually tick all the check boxes, so i can receive it on the other end
 submitForm('frmList', 'savefields');    
             
thanks for your help
0
 
hieloCommented:
>>please let me know , if its correct to have it like is then?
>>checkAll("on");
What I am saying is you don't even need checkAll function at all.
0
 
newbie27Author Commented:
Hielo,
how would I get the ids to process then? as I am passing the record id when the check box is  ticked..! please advice
thanks


0
 
hieloCommented:
>>how would I get the ids to process then?
Now, do you see what I was talking about?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now