Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

check all checkboxes

Posted on 2008-06-15
9
Medium Priority
?
446 Views
Last Modified: 2008-07-03
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
Comment
Question by:newbie27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21788493
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
 
LVL 2

Assisted Solution

by:Airyck666
Airyck666 earned 200 total points
ID: 21788936
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
 
LVL 82

Expert Comment

by:hielo
ID: 21789208
>>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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Author Comment

by:newbie27
ID: 21789419
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
 
LVL 82

Accepted Solution

by:
hielo earned 1800 total points
ID: 21789491
>>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
 
LVL 8

Author Comment

by:newbie27
ID: 21789519
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
 
LVL 82

Expert Comment

by:hielo
ID: 21789525
>>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
 
LVL 8

Author Comment

by:newbie27
ID: 21789567
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
 
LVL 82

Expert Comment

by:hielo
ID: 21789694
>>how would I get the ids to process then?
Now, do you see what I was talking about?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question