473,385 Members | 1,610 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,385 software developers and data experts.

inefficient to check value of a checkbox?

I have a big loop that checks the value of a checkbox several times
(1000+ times)
I'm just wondering, would it be any more efficient to save the value of
the checkbox outside the loop and the read that variable inside the
loop instead?

ie, I have this
for (var i=0;...)
doStuff (form1.checkbox1.checked);
versus
var chk = form1.checkbox1.checked;
for (var i=0;...)
doStuff (chk);

May 26 '06 #1
1 1220
Kourosh said the following on 5/26/2006 2:54 PM:
I have a big loop that checks the value of a checkbox several times
(1000+ times)
I'm just wondering, would it be any more efficient to save the value of
the checkbox outside the loop and the read that variable inside the
loop instead?

ie, I have this
for (var i=0;...)
doStuff (form1.checkbox1.checked);
versus
var chk = form1.checkbox1.checked;
for (var i=0;...)
doStuff (chk);


Do the second. It keeps from having to look up that property 1000 or so
times and as such will *always* be faster.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: John Banta | last post by:
Hi, I have created a 12 month calendar where each day has a check box whereby the user can indicate if that day is available or not available for a certain event. The calendar is 'drawn' in a...
2
by: Edward | last post by:
The following html / javascript code produces a simple form with check boxes. There is also a checkbox that 'checks all' form checkboxes hotmail style: <html> <head> <title></title> </head>...
2
by: jimi_xyz | last post by:
Sorry if this isn't the correct group, i don't think there is a group for straight HTML. I am trying to create a type of search engine. There are two radio buttons at the top, in the middle there...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
9
by: morellik | last post by:
Dear all, I have a program that creates dinamically a web page. In the page I have the following function to check how many checkbox are checked. function tarInfo(info) { var i=0; var c=0;...
4
by: it2051229 | last post by:
Well i'm having a problem with the compatibility of javascript and PHP multiple delete check box.. i used a javascript for the "CHECK ALL BOXES" just like yahoo mail.. so my input is something like...
1
by: rjoseph | last post by:
HI Guys I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK...
13
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
by: ghjk | last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 ) 1 means checked....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.