Is there anything incorrect or risky by writing
var i = edit_array[5] - 1;
document.form1. cbt[i].checked=true;
as
document.form1. cbt[edit_array[5]-1].checked=true;
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life. http://www.breastthermography.info 8 1071
Ed Jay wrote:
Is there anything incorrect or risky by writing
var i = edit_array[5] - 1;
document.form1. cbt[i].checked=true;
as
document.form1. cbt[edit_array[5]-1].checked=true;
If edit_array[5] <= 0, edit_array[5] % 1 != 0, or isNaN(edit_arra y[5]) ==
true, there is (probably) no document.form1. cbt[edit_array[5] - 1] and the
`checked' property lookup would throw a TypeError exception. With the first
approach you can test for the value of `i' before you use it, instead. In
any case you would want to test whether `document.form1 .cbt[i]' referred to
an object before you attempted to access its properties.
Besides,
document.forms["form1"].elements["cbt"][edit_array[5] - 1]
is the standards-compliant and backwards-compatible way to refer to form
control objects.
<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>
Thomas 'PointedEars' Lahn wrote:
>Ed Jay wrote:
>Is there anything incorrect or risky by writing
var i = edit_array[5] - 1; document.form1 .cbt[i].checked=true;
as
document.form1 .cbt[edit_array[5]-1].checked=true;
If edit_array[5] <= 0, edit_array[5] % 1 != 0, or isNaN(edit_arra y[5]) == true, there is (probably) no document.form1. cbt[edit_array[5] - 1] and the `checked' property lookup would throw a TypeError exception. With the first approach you can test for the value of `i' before you use it, instead. In any case you would want to test whether `document.form1 .cbt[i]' referred to an object before you attempted to access its properties.
edit_array[n] (and relevant form elements) always exist, and are thoroughly
tested for existence before the above..
> Besides,
document.forms["form1"].elements["cbt"][edit_array[5] - 1]
is the standards-compliant and backwards-compatible way to refer to form control objects.
<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
How important is this compliance issue? I have at least 100's of such
statements contained in some 15 scripts I would have to change.
Thank you for your input.
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life. http://www.breastthermography.info
Ed Jay wrote:
Thomas 'PointedEars' Lahn wrote:
>Ed Jay wrote:
>>Is there anything incorrect or risky by writing
var i = edit_array[5] - 1; document.form 1.cbt[i].checked=true;
as
document.form 1.cbt[edit_array[5]-1].checked=true;
If edit_array[5] <= 0, edit_array[5] % 1 != 0, or isNaN(edit_arra y[5]) == true, there is (probably) no document.form1. cbt[edit_array[5] - 1] and the `checked' property lookup would throw a TypeError exception. [...]
edit_array[n] (and relevant form elements) always exist, and are
thoroughly tested for existence before the above..
Then, and only then, it is a merely matter of taste and maintainability vs.
runtime efficiency.
>Besides,
document.for ms["form1"].elements["cbt"][edit_array[5] - 1]
is the standards-compliant and backwards-compatible way to refer to form control objects.
<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
How important is this compliance issue?
As important as you think adhering to industry standards is.
I have at least 100's of such statements contained in some 15 scripts I
would have to change.
Then you have probably done something very inefficient in the past, and it
would be about time that you refactored your code, even though advanced
search-and-replace could provide a quick fix. If you provided a sample of
it, one could make recommendations to that end.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Thomas 'PointedEars' Lahn wrote:
>Ed Jay wrote:
>Thomas 'PointedEars' Lahn wrote:
>>Ed Jay wrote: Is there anything incorrect or risky by writing
var i = edit_array[5] - 1; document.for m1.cbt[i].checked=true;
as
document.for m1.cbt[edit_array[5]-1].checked=true; If edit_array[5] <= 0, edit_array[5] % 1 != 0, or isNaN(edit_arra y[5]) == true, there is (probably) no document.form1. cbt[edit_array[5] - 1] and the `checked' property lookup would throw a TypeError exception. [...]
edit_array[n] (and relevant form elements) always exist, and are thoroughly tested for existence before the above..
Then, and only then, it is a merely matter of taste and maintainability vs. runtime efficiency.
>>Besides,
document.form s["form1"].elements["cbt"][edit_array[5] - 1]
is the standards-compliant and backwards-compatible way to refer to form control objects.
<http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
How important is this compliance issue?
As important as you think adhering to industry standards is.
>I have at least 100's of such statements contained in some 15 scripts I would have to change.
Then you have probably done something very inefficient in the past,
Clearly. I'm wondering where did I learn to code the wrong way.
and it would be about time that you refactored your code, even though advanced search-and-replace could provide a quick fix. If you provided a sample of it, one could make recommendations to that end.
A good sample is the format I posted. I'm quite interested in complying with
industry standards, so it appears I have some work to do. Amending
document.form1. variableName.wh atever to comply looks to be fairly simple
search/replace for the most part.
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life. http://www.breastthermography.info
Ed Jay wrote:
Thomas 'PointedEars' Lahn wrote:
....
>Then, and only then, it is a merely matter of taste and maintainabilit y vs. runtime efficiency.
Efficiency and performance is often mentioned in situations
like this. One could test the existence of an object typically
100 000 - one million times for one page load
before the extra delay would be annoying.
And writing 100 000 lines of existence tests is a lot of
work for the programmer, I guess.
As a user I could be happy to wait 0.000 01 seconds longer, if
I get a better program.
Ed Jay wrote:
Thomas 'PointedEars' Lahn wrote:
>Ed Jay wrote:
>>I have at least 100's of such statements contained in some 15 scripts I would have to change.
Then you have probably done something very inefficient in the past,
Clearly. I'm wondering where did I learn to code the wrong way.
>and it would be about time that you refactored your code, even though advanced search-and-replace could provide a quick fix. If you provided a sample of it, one could make recommendations to that end.
A good sample is the format I posted.
Not for this, it isn't. What I meant is, for example: Instead of writing
var x = a.b.c.d.e.f;
var y = a.b.c.d.e.g;
var z = a.b.c.f.e.h;
you should be writing
var o = a.b.c.d.e;
var x = o.f;
var y = o.g;
var z = o.h;
The same applies for property accesses that use the bracket form.
I'm quite interested in complying with industry standards, so it appears
I have some work to do. Amending document.form1. variableName.wh atever to
comply looks to be fairly simple search/replace for the most part.
Good luck, then.
Please trim your quotes to the minimum required to retain the context.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
In comp.lang.javas cript message <0a0vb4huf7f2nb 9kos9erb3uel1m4 lr4qa@4ax.
com>, Wed, 3 Sep 2008 23:35:30, Ed Jay <ed***@aes-intl.composted:
>Is there anything incorrect or risky by writing
var i = edit_array[5] - 1; document.form1 .cbt[i].checked=true;
as
document.form1 .cbt[edit_array[5]-1].checked=true;
Evidently the Great Ranter has not understood, or has wantonly ignored,
the exact point of your sufficiently well-phrased question, to which the
answer is "no, unless there are further lines using variable 'i' which
would also get expanded.". But it might be of negative benefit if 'i'
were a variable with an explanatory name serving as comment. And
there's some merit in avoiding 'i' in disseminated material, as it might
in some fonts be misread.
--
(c) John Stockton, nr London UK. ?@merlyn.demon. co.uk DOS 3.3 6.20 ; WinXP.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm- also batprogs.htm.
Dr J R Stockton wrote:
>In comp.lang.javas cript message <0a0vb4huf7f2nb 9kos9erb3uel1m4 lr4qa@4ax. com>, Wed, 3 Sep 2008 23:35:30, Ed Jay <ed***@aes-intl.composted:
>>Is there anything incorrect or risky by writing
var i = edit_array[5] - 1; document.form 1.cbt[i].checked=true;
as
document.form 1.cbt[edit_array[5]-1].checked=true;
Evidently the Great Ranter has not understood, or has wantonly ignored, the exact point of your sufficiently well-phrased question, to which the answer is "no, unless there are further lines using variable 'i' which would also get expanded.". But it might be of negative benefit if 'i' were a variable with an explanatory name serving as comment. And there's some merit in avoiding 'i' in disseminated material, as it might in some fonts be misread.
Thanks, John. :-)
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life. http://www.breastthermography.info This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fábio Mendes |
last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with
things or the python-list sent my msg to /dev/null. I couldn't find
anything related in previous PEP's, so here it goes a very early draft
for a new "assert" syntax:
This was inspired in Ruby's assert syntax. I'm not familiar with Ruby at
all, so the chances are that...
|
by: Nerox |
last post by:
Hi, If i write:
#include <stdio.h>
int foo(int);
int main(void){
int a = 3;
foo(a);
}
|
by: eman1000 |
last post by:
I was recently looking at the prototype library
(http://prototype.conio.net/) and I noticed the author used the
following syntax:
Object.extend(MyObj.prototype, {
my_meth1: function(){},
my_meth2: function(){}
});
to define new methods on the MyObj prototype object. Object.extend
|
by: Steven Bethard |
last post by:
The PEP below should be mostly self explanatory. I'll try to keep the
most updated versions available at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html
PEP: XXX
Title: The create statement
|
by: Steven Bethard |
last post by:
I've updated the PEP based on a number of comments on comp.lang.python.
The most updated versions are still at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html
In this post, I'm especially soliciting review of Carl Banks's point
(now discussed under Open Issues)...
| |
by: Steven Bethard |
last post by:
Ok, I finally have a PEP number. Here's the most updated version of the
"make" statement PEP. I'll be posting it shortly to python-dev.
Thanks again for the previous discussion and suggestions!
PEP: 359
Title: The "make" Statement
Version: $Revision: 45366 $
Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $
|
by: Steven Bethard |
last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The
patch is available at:
http://bugs.python.org/1472459
and I've pasted the full text below.
I've tried to be more explicit about the goals -- the make statement
is mostly syntactic sugar for::
class <name> <tuple>:
__metaclass__ = <callable>
|
by: Steve |
last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement
I got ASP error number 13 when I use the SELECT...FOR UPDATE statement
as below.
However, if I use SELECT statement without FOR UPDATE, it is fine and
no error.
I also tried Set objRs = objConn.Execute("SELECT * FROM EMP UPDATE OF
EMPNO"), but it still couldn't help.
...
|
by: dspfun |
last post by:
Hi!
The words "expression" and "statement" are often used in C99 and C-
textbooks, however, I am not sure of the clear defintion of these
words with respect to C.
Can somebody provide a sharp defintion of "expression" and
"statement"? What is the difference between an expression and a
statement?
|
by: florian.loitsch |
last post by:
According to the spec Section 14 the production
SourceElements:SourceElements SourceElement is evaluated as follows:
1. Evaluate SourceElements.
2. If Result(1) is an abrupt completion, return Result(1)
3. Evaluate SourceElement.
4. Return Result(3).
If I understood correctly the following program should alert
'undefined':...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |