Solved

how to call these two functions

Posted on 2008-06-17
12
204 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

705 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

18 Experts available now in Live!

Get 1:1 Help Now