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

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 1052
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
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
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
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
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
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
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
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
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
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
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
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.