Solved

how to call these two functions

Posted on 2008-06-17
12
209 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

837 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