Solved

how to call these two functions

Posted on 2008-06-17
12
208 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lazy load not working with masonry js 1 19
How to hide the rows in Table when the value is empty ? 4 40
HTML5 Get data in table rows 5 28
Jquery 2 11
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

772 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