Solved

how to call these two functions

Posted on 2008-06-17
12
206 Views
Last Modified: 2010-04-21
Hello Experts,

I have these two functions on the checkbox I am using in the attached function.


if(listID)=="#listDisplay"
  {display: '<input type="checkbox" name="chkAll" onclick="checkAllDefault(this.checked)"/> All', width : 30},
else
 {display: '<input type="checkbox" name="chkAll" onclick="checkAllDynamic(this.checked)"/> All', width : 30},

I have tried to do a check and apply the checkbox to the listViewer function but it did not work.

Please can you help.

Thanks
S


0
Comment
Question by:newbie27
  • 7
  • 5
12 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21804870
please have the top two function which I wanted to use listViewer

thanks for your help

function checkAllDefault(chkd)

{

      $("#listDisplay1 > tbody > tr > td > div > input.chkRefNos").each(function(){

                this.checked = chkd;

            });

}
 
 

function checkAllDynamic(chkd)

{

      $("#listDisplay > tbody > tr > td > div > input.chkRefNos").each(function(){

                this.checked = chkd;

            });

}
 

---------------------------------- 
 
 

function listViewer(listID, param1)

{     

     	$(listID).flexigrid

		({

        		url: 'list_proxy.asp?a=results',       

        		colModel : [                    

	{display: '<input type="checkbox" name="chkAll" onclick="checkAllDefault(this.checked)"/> All', width : 30},

                        	{display: 'Notes', name : 'notes', width : 50, sortable : false, align: 'left'},

           			{display: 'Contact    ', name : 'pe_rev_name', width : 150, sortable : true, align: 'left'},

                    	{display: 'Compnay Name  ', name : 'co_name', width : 200, sortable : true, align: 'left'},   

                    	{display: 'Flag  ', name : 'action_flag', width : 150, sortable : true, align: 'left'},

                    	{display: 'Group  ', name : 'co_group', width : 200, sortable : true, align: 'left'}                 

        			],

        		buttons : [                             

                         {name: 'Delete', bclass: 'delete', onpress : test},

					//	{name: 'Select All', bclass: 'add', onpress : test},

					//{name: 'DeSelect All', bclass: 'delete', onpress : test}

                                

                  	],                                      

        		sortname: '',

        		sortorder: 'asc',

        		usepager: false,

        		title: 'List Manager - ' + $("#drpLists").val(),

        		useRp: true,

        		rp: 1000,

        		query : param1+'&Fields=ref_no,notes,pe_rev_name,co_name,action_flag,co_group',         

        		showTableToggleBtn: true,                       

        		width: 760,

        		height: 350,

				onSuccess:function()

	   			{

                		$(".edit_area").editable( 

						function(value, settings) { return(value); }, 

                			{     

							submit    : "OK",

							indicator : "process..........",

							tooltip   : "Click to edit...",

							style  : "inherit" 

                			}

					);

				}

        		

        	});

 

}

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 21804939
Try having a single function that takes an id parameter:
function checkAll(id )
{
      $( id +" > tbody > tr > td > div > input.chkRefNos").each(function(){
                this.checked = chkd;
            });
}

and then your checkboxes would be:
if(listID)=="#listDisplay"
  {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay\')"/> All', width : 30},
else
 {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay1\')"/> All', width : 30},
0
 
LVL 8

Author Comment

by:newbie27
ID: 21805019
I am getting syntax error here Hielo.

if(listID)=="#listDisplay"   ---> this line
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay\')"/> All', width : 30},
                              else
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay1\')"/> All', width : 30},
                        
syntax error

[Break on this error] if(listID)=="#listDisplay"\n

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 21805055
instead of \' use &#39;

if(listID)=="#listDisplay"   ---> this line
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All', width : 30},
                              else
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All', width : 30},
0
 
LVL 8

Author Comment

by:newbie27
ID: 21805173
I have Hielo, apparently it is still giving the same error
syntax error

[Break on this error] if(listID)=="#listDisplay" \n

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
ID: 21805182
I think we cannot add any condition within that block in Flexigrid,...? I guess ...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 82

Expert Comment

by:hielo
ID: 21805196
>>I think we cannot add any condition within that block ..
COrrect. You have to do the if outside of that block.
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21805225
you might be able to use the ternary operator:
( listID=="#listDisplay") ? {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All', width : 30} : {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All', width : 30},

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
ID: 21805270
OK Hielo,
I have done something like this but still says the same

please see for "chkShow"
 var chkShow;

		if(listID)=="#listDisplay"  

           chkShow = '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All';

       else

           chkShow = '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All';
 

		$(listID).flexigrid

		({

        		url: 'list_proxy.asp?a=results',       

        		colModel : [                    

                 	    {display: chkShow, width : 30},

Open in new window

0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31468038
yes this has worked...thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 21805339
                   colModel : [                    
                  //   {display: ' ', name : 'chkDelete', width : 30, sortable : false, align: 'left'},
                           {display: ( listID=="#listDisplay" ? '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All' : '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All'), width : 30},

                              {display: 'Notes', name : 'notes', width : 50, sortable : false, align: 'left'},
                                    {display: 'Contact    ', name : 'pe_rev_name', width : 150, sortable : true, align: 'left'},
                          {display: 'Compnay Name  ', name : 'co_name', width : 200, sortable : true, align: 'left'},  
                          {display: 'Flag  ', name : 'action_flag', width : 150, sortable : true, align: 'left'},
                          {display: 'Group  ', name : 'co_group', width : 200, sortable : true, align: 'left'}                
                          ],
0
 
LVL 8

Author Comment

by:newbie27
ID: 21805416
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now