473,394 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HELP: Slow response in checkbox using javascript and ajax

Hi everyone. Im trying to optimize a website. But im stuck with this code here. My problem is when i check/uncheck the checkbox it took 5-6 sec just by clicking it. Could anyone help me rewrite this code?. please

Expand|Select|Wrap|Line Numbers
  1. function checkAccess(celDiv,id)
  2. {
  3.     var celValue = $(celDiv).html();
  4.  
  5.     if (celValue==1) $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' checked disabled>")//display detFlex1
  6.     else $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' disabled>")//convert value of checkbox to 0/1    
  7.  
  8.     $(celDiv).click
  9.     (
  10.          function()
  11.         {
  12.             $('input',this).each(
  13.                  function(){
  14.  
  15.                     tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent());    
  16.                     td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
  17.                     td_last = 13;
  18.                 for(var td=td_idx+1; td<=td_last;td++)
  19.                 {
  20.                     if ($(this).attr('checked') == true) 
  21.                     {
  22.                                 df[0].rows[tr_idx].cell[td_idx] = 1;//index[1] = Full Access
  23.                         if (td_idx==3) 
  24.                             {
  25.                                 df[0].rows[tr_idx].cell[td] = 1;
  26.                             }        
  27.                                 df[0].rows[tr_idx].cell[2] = 1;
  28.                         if (td_idx > 3)
  29.                             {
  30.                                 df[0].rows[tr_idx].cell[2] = 1;
  31.                             }                        
  32.                     }
  33.                     else 
  34.                     {            
  35.                                 df[0].rows[tr_idx].cell[td_idx] = 0;//index[0] = With Access
  36.                         if (td_idx==2) 
  37.                             {
  38.                                 df[0].rows[tr_idx].cell[td] = 0;
  39.                             }
  40.                         else if (td_idx==3) 
  41.                             {                            
  42.                                 df[0].rows[tr_idx].cell[td] = 0;                        
  43.                             }                            
  44.                         if (td_idx > 3)
  45.                             {
  46.                                 df[0].rows[tr_idx].cell[3] = 0;
  47.                             }
  48.                     }
  49.                 }
  50.                     $('#detFlex1').flexAddData(df[0]);
  51.                     $('.toolbar a[title=Edit Item]').trigger('click');
  52.                  });    
  53.         }
  54.     );
  55. }
Attached Files
File Type: txt javascript.txt (4.9 KB, 375 views)
Oct 6 '09 #1
7 3206
Dormilich
8,658 Expert Mod 8TB
do you have a site where I can check that? At first glance I don’t see a cause for such a delay, so I’d use FireBug to check that.
Oct 6 '09 #2
Hi, Dormilich

Thanks for checking the codes. I am also using Firebug. No error is being displayed. I'm suggesting of redoing the javascript code but im still a newbie xD.

This is an open source web app.
http://www.comunionerp.com/web/sec_users/login

PS: if you are interested in contributing some codes then please add me in ym: <email_removed>

Thanks
-Dean
Oct 6 '09 #3
Dormilich
8,658 Expert Mod 8TB
@kikz4life
I don’t want to check the code for correctness, I want to see if I can find the line that takes so long using the breakpoints.
Oct 6 '09 #4
Dormilich
8,658 Expert Mod 8TB
@kikz4life
the page responds reasonably well, maybe your connection is too slow? (despite I’m not sure, whether this is the page you’re talking about, since I didn’t find the ids and classes from the code)
Oct 6 '09 #5
Expand|Select|Wrap|Line Numbers
  1. $(celDiv).click
  2.     (
  3.          function()
  4.         {
  5.             $('input',this).each(
  6.                  function(){
  7.  
  8.                     var tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent());    
  9.                     var td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
  10.                     var td_last = 13;
  11.             ............
  12.                  });    
  13.         }
  14.     );
  15. }
i'm thinking that the problem is within this code. What do u think.?

Thanks again
-Dean
Oct 6 '09 #6
@Dormilich
have u tried the site? the problem is not in the the login page. Its in the User Access Level located at the side nav in the main page under Administrator Module. http://www.comunionerp.com/web/sec_accesslevel
Oct 6 '09 #7
awts, i cant login. someone change the password of admin again.. X-(.

anyway i have attach a .bmp. this is how it looks like in the page(attached).
Attached Images
File Type: jpg checkbox.jpg (18.5 KB, 521 views)
Oct 6 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jack | last post by:
I have a asp form where among others there are few text boxes and one check box. The checkbox is to indicate whether the entry is final. The checkbox is attahced to a field in table of type...
4
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
10
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response...
3
by: cold80 | last post by:
I was just doing a performance test in order to see the benefit of using AJAX instead of doing a postback on the server. So I have a simple page that performs a request to the server and write a...
1
by: empiresolutions | last post by:
im using the script.aculo.us drag n drop script. i am having an issue getting a checkbox to POST its value if checked, once the row the checkbox is in is moved. I believe that once i change the...
5
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.