473,487 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax help please

I'm trying to put:

document.form1.proto0[0].checked=true;
document.form1.proto1[0].checked = true;
document.form1.proto2[0].checked = true;
..
..
document.form1.proton[0].checked =true;

into a loop. I've unsuccessfully tried:

for (var i=0;i<n+1;i++) {
document.form1.proto+i+[0].checked=true;
}

and I've been unsuccessful using:

for (var i=0;i<n+1;i++) {
document.forms["form1"].elements["proto"+i+"[0]"].checked=true;
}

Syntax-wise, where am I going astray?

--
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
Sep 6 '08 #1
7 1058
Ed Jay <ed***@aes-intl.comwrites:
I'm trying to put:

document.form1.proto0[0].checked=true;
document.form1.proto1[0].checked = true;
document.form1.proto2[0].checked = true;
.
.
document.form1.proton[0].checked =true;

into a loop.
Smart move. :)

....
and I've been unsuccessful using:

for (var i=0;i<n+1;i++) {
document.forms["form1"].elements["proto"+i+"[0]"].checked=true;
This was close!
}

Syntax-wise, where am I going astray?
The [0] is not part of the name. The name is "proto2", and there
are apparently more elements in the form with that name.
Try:

var elems = document.form["form1"].elements;
for(var i = 0; i < n; i++) {
elems["proto"+i][0].checked = true;
}

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Sep 6 '08 #2
Ed Jay wrote on 06 sep 2008 in comp.lang.javascript:
document.forms["form1"].elements["proto"+i+"[0]"].checked=true;
Methinks:

document.forms["form1"].elements["proto"+i][0].checked=true;

[If these are radio buttons]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 6 '08 #3
Evertjan. wrote:
>Ed Jay wrote on 06 sep 2008 in comp.lang.javascript:
>document.forms["form1"].elements["proto"+i+"[0]"].checked=true;

Methinks:

document.forms["form1"].elements["proto"+i][0].checked=true;

[If these are radio buttons]
They are, indeed. I have several rows of two buttons each that I'm setting
if a preceding condition is met.

--
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
Sep 6 '08 #4
Lasse Reichstein Nielsen wrote:
>Ed Jay <ed***@aes-intl.comwrites:
>I'm trying to put:

document.form1.proto0[0].checked=true;
document.form1.proto1[0].checked = true;
document.form1.proto2[0].checked = true;

into a loop.
>and I've been unsuccessful using:

for (var i=0;i<n+1;i++) {
document.forms["form1"].elements["proto"+i+"[0]"].checked=true;
}
>Syntax-wise, where am I going astray?

The [0] is not part of the name. The name is "proto2", and there
are apparently more elements in the form with that name.
Try:

var elems = document.form["form1"].elements;
for(var i = 0; i < n; i++) {
elems["proto"+i][0].checked = true;
}
Thanks, but it's not working. I continue to receive an error msg:
"Cannot convert undefined or null to Object." (The original multi-line,
non-loop command works fine.)

By way of elaboration, this issue pertains to multiple rows of radio button
pairs that I'm setting pursuant to a previous condition being met, e.g.,.
proto0[0] and proto0[1], etc.

--
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
Sep 6 '08 #5
Ed Jay meinte:
Lasse Reichstein Nielsen wrote:
>var elems = document.form["form1"].elements;
^^^^
Typo - should be document.forms[...]

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Sep 6 '08 #6
Gregor Kofler wrote:
>Ed Jay meinte:
>Lasse Reichstein Nielsen wrote:
>>var elems = document.form["form1"].elements;
^^^^
Typo - should be document.forms[...]
Teach me to cut and paste! :-)

Works.

--
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
Sep 6 '08 #7
Ed Jay wrote:
>Lasse Reichstein Nielsen wrote:
>>Ed Jay <ed***@aes-intl.comwrites:
>>I'm trying to put:

document.form1.proto0[0].checked=true;
document.form1.proto1[0].checked = true;
document.form1.proto2[0].checked = true;

into a loop.
>>and I've been unsuccessful using:

for (var i=0;i<n+1;i++) {
document.forms["form1"].elements["proto"+i+"[0]"].checked=true;
}
>>Syntax-wise, where am I going astray?

The [0] is not part of the name. The name is "proto2", and there
are apparently more elements in the form with that name.
Try:

var elems = document.form["form1"].elements;
for(var i = 0; i < n; i++) {
elems["proto"+i][0].checked = true;
}
Thanks, but it's not working. I continue to receive an error msg:
"Cannot convert undefined or null to Object." (The original multi-line,
non-loop command works fine.)

By way of elaboration, this issue pertains to multiple rows of radio button
pairs that I'm setting pursuant to a previous condition being met, e.g.,.
proto0[0] and proto0[1], etc.
Now that Gregor Kofler has pointed out the typo, it works great. Thanks,
Lasse.

--
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
Sep 6 '08 #8

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

Similar topics

14
2279
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def...
29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
14
3622
by: aaron kempf | last post by:
I find that ADP does not support any Stored Procedures that use the 'CREATE PROC spHAPPY' syntax. CREATE PROC syntax is listed in books online. This syntax should be supported Here is a...
21
2307
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload...
2
1956
by: coolindienc | last post by:
Today I am going nuts. This is another one that is not working. It keeps giving me syntax error at highlighted line. No matter what I do I still have that error at the same line. It seems that my...
20
2556
by: W Karas | last post by:
Would the fear factor for concepts be slightly reduced if, instead of: concept C<typename T> { typename T::S; int T::mem(); int nonmem(); };
7
2861
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
2
2573
by: Chris Walls | last post by:
We have created two (2) global resource files in App_GlobalResouces: Global.resx Global.es-MX.resx In an ASP.NET page, we use two different syntaxes to set text on the page, depending upon the...
7
1511
by: krishna | last post by:
What is the need of this syntax for initializing values, isn't this ambiguous to function call? e.g., int func_name(20); this looks like function call (of course not totally as there is no...
6
2537
by: Daniel | last post by:
I hope this question is OK for this list. I've downloaded Rpyc and placed it in my site packages dir. On some machines it works fine, on others not so much. Here is one error I get when I try...
0
7105
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
6967
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
7132
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
7180
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...
1
6846
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...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1381
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 ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.